Browse Source

Merge branch 'master' of https://github.com/nextcloud/android into syncedFolders

# Conflicts:
#	src/com/owncloud/android/MainApp.java
#	src/com/owncloud/android/db/ProviderMeta.java
#	src/com/owncloud/android/providers/FileContentProvider.java
#	src/com/owncloud/android/services/observer/FolderObserver.java
#	src/com/owncloud/android/ui/activity/Preferences.java
AndyScherzinger 8 years ago
parent
commit
6c8bbd6c2c
100 changed files with 1258 additions and 1025 deletions
  1. 1 1
      README.md
  2. 1 0
      build.gradle
  3. 1 0
      pmd-ruleset.xml
  4. 1 2
      res/values-bg-rBG/strings.xml
  5. 28 0
      res/values-cs-rCZ/strings.xml
  6. 28 0
      res/values-de-rDE/strings.xml
  7. 29 1
      res/values-de/strings.xml
  8. 1 1
      res/values-el/strings.xml
  9. 28 0
      res/values-en-rGB/strings.xml
  10. 1 2
      res/values-es/strings.xml
  11. 13 1
      res/values-fr/strings.xml
  12. 28 0
      res/values-hu-rHU/strings.xml
  13. 1 1
      res/values-id/strings.xml
  14. 1 2
      res/values-is/strings.xml
  15. 28 0
      res/values-it/strings.xml
  16. 1 2
      res/values-ko/strings.xml
  17. 25 0
      res/values-nb-rNO/strings.xml
  18. 31 3
      res/values-nl/strings.xml
  19. 24 1
      res/values-pl/strings.xml
  20. 29 0
      res/values-pt-rBR/strings.xml
  21. 2 2
      res/values-ru/strings.xml
  22. 1 2
      res/values-sl/strings.xml
  23. 1 2
      res/values-sq/strings.xml
  24. 5 6
      res/values-sv/strings.xml
  25. 1 1
      res/values-tr/strings.xml
  26. 1 2
      res/values-zh-rTW/strings.xml
  27. 8 4
      src/com/owncloud/android/MainApp.java
  28. 3 6
      src/com/owncloud/android/authentication/AccountAuthenticator.java
  29. 7 8
      src/com/owncloud/android/authentication/AccountUtils.java
  30. 26 31
      src/com/owncloud/android/authentication/AuthenticatorActivity.java
  31. 2 2
      src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java
  32. 1 1
      src/com/owncloud/android/authentication/PassCodeManager.java
  33. 182 259
      src/com/owncloud/android/datamodel/FileDataStorageManager.java
  34. 18 10
      src/com/owncloud/android/datamodel/OCFile.java
  35. 40 37
      src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
  36. 6 5
      src/com/owncloud/android/datamodel/UploadsStorageManager.java
  37. 8 4
      src/com/owncloud/android/datastorage/DataStorageProvider.java
  38. 4 2
      src/com/owncloud/android/datastorage/UniqueStorageList.java
  39. 16 12
      src/com/owncloud/android/datastorage/providers/AbstractCommandLineStoragePoint.java
  40. 11 5
      src/com/owncloud/android/datastorage/providers/AbstractStoragePointProvider.java
  41. 6 3
      src/com/owncloud/android/datastorage/providers/EnvironmentStoragePointProvider.java
  42. 5 3
      src/com/owncloud/android/datastorage/providers/HardcodedStoragePointProvider.java
  43. 8 5
      src/com/owncloud/android/datastorage/providers/MountCommandStoragePointProvider.java
  44. 4 2
      src/com/owncloud/android/datastorage/providers/VDCStoragePointProvider.java
  45. 10 7
      src/com/owncloud/android/db/ProviderMeta.java
  46. 1 1
      src/com/owncloud/android/files/BootupBroadcastReceiver.java
  47. 4 4
      src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java
  48. 13 15
      src/com/owncloud/android/files/services/ConnectivityActionReceiver.java
  49. 11 4
      src/com/owncloud/android/files/services/FileDownloader.java
  50. 16 6
      src/com/owncloud/android/files/services/FileUploader.java
  51. 1 1
      src/com/owncloud/android/files/services/IndexedForest.java
  52. 0 28
      src/com/owncloud/android/files/services/OnUploadCompletedListener.java
  53. 23 23
      src/com/owncloud/android/media/MediaControlView.java
  54. 6 4
      src/com/owncloud/android/media/MediaService.java
  55. 3 5
      src/com/owncloud/android/operations/CreateShareWithShareeOperation.java
  56. 6 4
      src/com/owncloud/android/operations/DownloadFileOperation.java
  57. 5 6
      src/com/owncloud/android/operations/GetCapabilitiesOperarion.java
  58. 11 14
      src/com/owncloud/android/operations/OAuth2GetAccessToken.java
  59. 3 1
      src/com/owncloud/android/operations/RefreshFolderOperation.java
  60. 4 2
      src/com/owncloud/android/operations/RenameFileOperation.java
  61. 4 4
      src/com/owncloud/android/operations/SynchronizeFileOperation.java
  62. 2 1
      src/com/owncloud/android/operations/SynchronizeFolderOperation.java
  63. 2 1
      src/com/owncloud/android/operations/UpdateOCVersionOperation.java
  64. 17 8
      src/com/owncloud/android/operations/UploadFileOperation.java
  65. 2 1
      src/com/owncloud/android/operations/common/SyncOperation.java
  66. 153 144
      src/com/owncloud/android/providers/FileContentProvider.java
  67. 2 8
      src/com/owncloud/android/services/OperationsService.java
  68. 6 9
      src/com/owncloud/android/services/SyncFolderHandler.java
  69. 1 1
      src/com/owncloud/android/services/observer/FileObserverService.java
  70. 10 7
      src/com/owncloud/android/services/observer/FolderObserver.java
  71. 13 18
      src/com/owncloud/android/syncadapter/FileSyncAdapter.java
  72. 1 1
      src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java
  73. 44 47
      src/com/owncloud/android/ui/activity/FileDisplayActivity.java
  74. 3 4
      src/com/owncloud/android/ui/activity/FolderPickerActivity.java
  75. 5 7
      src/com/owncloud/android/ui/activity/GenericExplanationActivity.java
  76. 7 4
      src/com/owncloud/android/ui/activity/LogHistoryActivity.java
  77. 0 8
      src/com/owncloud/android/ui/activity/ManageAccountsActivity.java
  78. 8 5
      src/com/owncloud/android/ui/activity/PassCodeActivity.java
  79. 28 31
      src/com/owncloud/android/ui/activity/Preferences.java
  80. 13 11
      src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java
  81. 43 33
      src/com/owncloud/android/ui/activity/StorageMigration.java
  82. 8 7
      src/com/owncloud/android/ui/activity/UploadFilesActivity.java
  83. 12 11
      src/com/owncloud/android/ui/adapter/DiskLruImageCache.java
  84. 4 1
      src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java
  85. 9 12
      src/com/owncloud/android/ui/adapter/FileListListAdapter.java
  86. 6 8
      src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java
  87. 2 1
      src/com/owncloud/android/ui/adapter/UploaderAdapter.java
  88. 1 1
      src/com/owncloud/android/ui/adapter/X509CertificateViewAdapter.java
  89. 3 5
      src/com/owncloud/android/ui/asynctasks/CopyAndUploadContentUrisTask.java
  90. 10 7
      src/com/owncloud/android/ui/dialog/ConfirmationDialogFragment.java
  91. 6 3
      src/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java
  92. 3 2
      src/com/owncloud/android/ui/dialog/CredentialsDialogFragment.java
  93. 2 1
      src/com/owncloud/android/ui/dialog/LoadingDialog.java
  94. 2 1
      src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java
  95. 1 1
      src/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java
  96. 1 5
      src/com/owncloud/android/ui/dialog/SamlWebViewDialog.java
  97. 2 1
      src/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java
  98. 9 14
      src/com/owncloud/android/ui/dialog/SslValidatorDialog.java
  99. 28 31
      src/com/owncloud/android/ui/errorhandling/ExceptionHandler.java
  100. 2 4
      src/com/owncloud/android/ui/fragment/EditShareFragment.java

+ 1 - 1
README.md

@@ -1,4 +1,4 @@
-# [Nextcloud](https://nextcloud.com) Android app [![Build Status](https://drone.nextcloud.com/api/badges/nextcloud/android/status.svg)](https://drone.nextcloud.com/nextcloud/android) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bbf503cdfec6441e853160135706723e)](https://www.codacy.com/app/Nextcloud/android?utm_source=github.com&utm_medium=referral&utm_content=nextcloud/android&utm_campaign=Badge_Grade)
+# [Nextcloud](https://nextcloud.com) Android app [![Build Status](https://drone.nextcloud.com/api/badges/nextcloud/android/status.svg)](https://drone.nextcloud.com/nextcloud/android) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/80401cb343854343b4d94acbfb72d3ec)](https://www.codacy.com/app/Nextcloud/android?utm_source=github.com&utm_medium=referral&utm_content=nextcloud/android&utm_campaign=Badge_Grade)
 
 [<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" 
       alt="Download from Google Play" 

+ 1 - 0
build.gradle

@@ -47,6 +47,7 @@ dependencies {
     compile 'com.jakewharton:disklrucache:2.0.2'
     compile "com.android.support:appcompat-v7:${supportLibraryVersion}"
     compile 'com.getbase:floatingactionbutton:1.10.1'
+    compile 'com.google.code.findbugs:annotations:2.0.1'
 
 
     /// dependencies for local unit tests

+ 1 - 0
pmd-ruleset.xml

@@ -9,6 +9,7 @@
     </description>
     <exclude-pattern>.*/R.java</exclude-pattern>
     <exclude-pattern>.*/gen/.*</exclude-pattern>
+    <exclude-pattern>.*/third_parties/.*</exclude-pattern>
 
     <rule ref="rulesets/java/logging-java.xml" />
     <rule ref="rulesets/java/braces.xml" />

+ 1 - 2
res/values-bg-rBG/strings.xml

@@ -415,7 +415,6 @@
     <string name="pref_behaviour_entries_keep_file">запазвани в оригиналната папка</string>
     <string name="pref_behaviour_entries_move">премествани в папката на приложението</string>
     <string name="pref_behaviour_entries_delete_file">изтривани</string>
-
     <string name="share_dialog_title">Споделяне</string>
     <string name="share_file">Споделяне на %1$s</string>
     <string name="share_with_user_section_title">Споделяне с потребители и групи</string>
@@ -471,4 +470,4 @@
         <item quantity="other">%d избрани</item>
     </plurals>
 
-</resources>
+    </resources>

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

@@ -355,6 +355,28 @@ správce systému.</string>
     <string name="uploader_upload_forbidden_permissions">nahrávat do tohoto adresáře</string>
     <string name="downloader_download_file_not_found">Tento soubor již není dostupný na serveru</string>
 
+    <string name="file_migration_dialog_title">Aktualizace cesty k úložišti</string>
+    <string name="file_migration_finish_button">Dokončit</string>
+    <string name="file_migration_preparing">Příprava na migraci&#8230;</string>
+    <string name="file_migration_checking_destination">Prověřování cílového umístění&#8230;</string>
+    <string name="file_migration_saving_accounts_configuration">Ukládání konfigurace účtů&#8230;</string>
+    <string name="file_migration_waiting_for_unfinished_sync">Čekání na nedokončené synchronizace&#8230;</string>
+    <string name="file_migration_migrating">Přesun dat&#8230;</string>
+    <string name="file_migration_updating_index">Aktualizace indexu&#8230;</string>
+    <string name="file_migration_cleaning">Čištění&#8230;</string>
+    <string name="file_migration_restoring_accounts_configuration">Obnovování konfigurace účtů&#8230;</string>
+    <string name="file_migration_ok_finished">Dokončeno</string>
+    <string name="file_migration_failed_not_enough_space">CHYBA: Nedostatek volného prostoru</string>
+    <string name="file_migration_failed_not_writable">CHYBA: Do souboru nelze zapisovat</string>
+    <string name="file_migration_failed_not_readable">CHYBA: Soubor nelze číst</string>
+    <string name="file_migration_failed_dir_already_exists">CHYBA: Nextcloud adresář již existuje</string>
+    <string name="file_migration_failed_while_coping">CHYBA: V průběhu migrace</string>
+    <string name="file_migration_failed_while_updating_index">CHYBA: V průběhu aktualizace indexu</string>
+
+    <string name="file_migration_directory_already_exists">Datový adresář již existuje, co teď?</string>
+    <string name="file_migration_override_data_folder">Přepsat</string>
+    <string name="file_migration_use_data_folder">Použít existující</string>
+
     <string name="prefs_category_accounts">Účty</string>
     <string name="prefs_add_account">Přidat účet</string>
     <string name="drawer_manage_accounts">Spravovat účty</string>
@@ -421,6 +443,8 @@ správce systému.</string>
     <string name="pref_behaviour_entries_keep_file">ponechán ve výchozím adresáři</string>
     <string name="pref_behaviour_entries_move">přesunut do adresáře aplikace</string>
     <string name="pref_behaviour_entries_delete_file">smazáno</string>
+    <string name="prefs_storage_path">Cesta k úložišti</string>
+    <string name="prefs_common">Obvyklý</string>
 
     <string name="share_dialog_title">Sdílení</string>
     <string name="share_file">Sdílet %1$s</string>
@@ -497,4 +521,8 @@ správce systému.</string>
         <item quantity="other">vybráno %d</item>
     </plurals>
 
+    <string name="storage_description_default">Výchozí</string>
+    <string name="storage_description_sd_no">SD karta %1$d</string>
+    <string name="storage_description_unknown">Neznámý</string>
+
 </resources>

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

@@ -356,6 +356,28 @@
     <string name="uploader_upload_forbidden_permissions">in diesem Order etwas hochzuladen</string>
     <string name="downloader_download_file_not_found">Diese Datei steht auf dem Server nicht mehr zur Verfügung</string>
 
+    <string name="file_migration_dialog_title">Aktualisiere Speicherort</string>
+    <string name="file_migration_finish_button">Beenden</string>
+    <string name="file_migration_preparing">Bereite Migration vor&#8230;</string>
+    <string name="file_migration_checking_destination">Prüfe Zielort&#8230;</string>
+    <string name="file_migration_saving_accounts_configuration">Speichere Konteneinstellung&#8230;</string>
+    <string name="file_migration_waiting_for_unfinished_sync">Warte auf Abschluss der Synchronisierungen&#8230;</string>
+    <string name="file_migration_migrating">Verschiebe Dateien&#8230;</string>
+    <string name="file_migration_updating_index">Aktualisiere Index&#8230;</string>
+    <string name="file_migration_cleaning">Aufräumen&#8230;</string>
+    <string name="file_migration_restoring_accounts_configuration">Konteneinstellung wiederherstellen&#8230;</string>
+    <string name="file_migration_ok_finished">Abgeschlossen</string>
+    <string name="file_migration_failed_not_enough_space">FEHLER: Nicht genügend Speicherplatz</string>
+    <string name="file_migration_failed_not_writable">FEHLER: Datei kann nicht geschrieben werden</string>
+    <string name="file_migration_failed_not_readable">FEHLER: Datei nicht lesbar</string>
+    <string name="file_migration_failed_dir_already_exists">FEHLER: Nextcloud Ordner existiert bereits</string>
+    <string name="file_migration_failed_while_coping">FEHLER: Während der Migration</string>
+    <string name="file_migration_failed_while_updating_index">FEHLER: Während der Aktualisierung des Indixes</string>
+
+    <string name="file_migration_directory_already_exists">Datenordner existiert bereits, was soll getan werden?</string>
+    <string name="file_migration_override_data_folder">Überschreiben</string>
+    <string name="file_migration_use_data_folder">Verwende Bestehenden</string>
+
     <string name="prefs_category_accounts">Konten</string>
     <string name="prefs_add_account">Konto hinzufügen</string>
     <string name="drawer_manage_accounts">Konten verwalten</string>
@@ -422,6 +444,8 @@
     <string name="pref_behaviour_entries_keep_file">im Originalordner behalten</string>
     <string name="pref_behaviour_entries_move">in den App-Ordner verschoben</string>
     <string name="pref_behaviour_entries_delete_file">gelöscht</string>
+    <string name="prefs_storage_path">Speicherort</string>
+    <string name="prefs_common">Allgemein</string>
 
     <string name="share_dialog_title">Teilen</string>
     <string name="share_file">%1$s teilen</string>
@@ -497,4 +521,8 @@
         <item quantity="other">%d ausgewählt</item>
     </plurals>
 
+    <string name="storage_description_default">Standard</string>
+    <string name="storage_description_sd_no">SD Karte %1$d</string>
+    <string name="storage_description_unknown">Unbekannt</string>
+
 </resources>

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

@@ -356,6 +356,28 @@
     <string name="uploader_upload_forbidden_permissions">in diesem Order etwas hochzuladen</string>
     <string name="downloader_download_file_not_found">Diese Datei steht auf dem Server nicht mehr zur Verfügung</string>
 
+    <string name="file_migration_dialog_title">Aktualisiere Speicherort</string>
+    <string name="file_migration_finish_button">Beenden</string>
+    <string name="file_migration_preparing">Bereite Migration vor&#8230;</string>
+    <string name="file_migration_checking_destination">Prüfe Zielort&#8230;</string>
+    <string name="file_migration_saving_accounts_configuration">Speichere Konteneinstellung&#8230;</string>
+    <string name="file_migration_waiting_for_unfinished_sync">Warte auf Abschluss der Synchronisierungen&#8230;</string>
+    <string name="file_migration_migrating">Verschiebe Dateien&#8230;</string>
+    <string name="file_migration_updating_index">Aktualisiere Index&#8230;</string>
+    <string name="file_migration_cleaning">Aufräumen&#8230;</string>
+    <string name="file_migration_restoring_accounts_configuration">Konteneinstellung wiederherstellen&#8230;</string>
+    <string name="file_migration_ok_finished">Abgeschlossen</string>
+    <string name="file_migration_failed_not_enough_space">FEHLER: Nicht genügend Speicherplatz</string>
+    <string name="file_migration_failed_not_writable">FEHLER: Datei kann nicht geschrieben werden</string>
+    <string name="file_migration_failed_not_readable">FEHLER: Datei nicht lesbar</string>
+    <string name="file_migration_failed_dir_already_exists">FEHLER: Nextcloud Ordner existiert bereits</string>
+    <string name="file_migration_failed_while_coping">FEHLER: Während der Migration</string>
+    <string name="file_migration_failed_while_updating_index">FEHLER: Während der Aktualisierung des Indixes</string>
+
+    <string name="file_migration_directory_already_exists">Datenordner existiert bereits, was soll getan werden?</string>
+    <string name="file_migration_override_data_folder">Überschreiben</string>
+    <string name="file_migration_use_data_folder">Verwende Bestehenden</string>
+
     <string name="prefs_category_accounts">Konten</string>
     <string name="prefs_add_account">Konto hinzufügen</string>
     <string name="drawer_manage_accounts">Benutzerkonten verwalten</string>
@@ -422,6 +444,8 @@
     <string name="pref_behaviour_entries_keep_file">im Originalordner behalten</string>
     <string name="pref_behaviour_entries_move">in den App-Ordner verschoben</string>
     <string name="pref_behaviour_entries_delete_file">gelöscht</string>
+    <string name="prefs_storage_path">Speicherort</string>
+    <string name="prefs_common">Allgemein</string>
 
     <string name="share_dialog_title">Teilen</string>
     <string name="share_file">Teile %1$s</string>
@@ -463,7 +487,7 @@
     <string name="action_switch_grid_view">Rasteransicht</string>
     <string name="action_switch_list_view">Listenansicht</string>
 
-    <string name="manage_space_title">verwalte Speicherplatz</string>
+    <string name="manage_space_title">Verwalte Speicherplatz</string>
     <string name="manage_space_description">Einstellungen, Datenbank und Server-Zertifikate von %1$s\'s Daten werden dauerhaft gelöscht.\n\nHerunter geladene Dateien bleiben unangetastet.\n\nDieser Vorgang kann eine Zeit dauern.</string>
     <string name="manage_space_clear_data">Daten löschen</string>
     <string name="manage_space_error">Einige Dateien konnten nicht gelöscht werden.</string>
@@ -497,4 +521,8 @@
         <item quantity="other">%d ausgewählt</item>
     </plurals>
 
+    <string name="storage_description_default">Standard</string>
+    <string name="storage_description_sd_no">SD Karte %1$d</string>
+    <string name="storage_description_unknown">Unbekannt</string>
+
 </resources>

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

@@ -440,4 +440,4 @@
         <item quantity="other">%d επιλέχθηκαν</item>
     </plurals>
 
-</resources>
+    </resources>

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

@@ -356,6 +356,28 @@
     <string name="uploader_upload_forbidden_permissions">to upload to this folder</string>
     <string name="downloader_download_file_not_found">The file is no longer available on the server</string>
 
+    <string name="file_migration_dialog_title">Updating storage path</string>
+    <string name="file_migration_finish_button">Finish</string>
+    <string name="file_migration_preparing">Preparing for migration&#8230;</string>
+    <string name="file_migration_checking_destination">Checking destination&#8230;</string>
+    <string name="file_migration_saving_accounts_configuration">Saving accounts configuration&#8230;</string>
+    <string name="file_migration_waiting_for_unfinished_sync">Waiting for unfinished synchronizations&#8230;</string>
+    <string name="file_migration_migrating">Moving data&#8230;</string>
+    <string name="file_migration_updating_index">Updating index&#8230;</string>
+    <string name="file_migration_cleaning">Cleaning&#8230;</string>
+    <string name="file_migration_restoring_accounts_configuration">Restoring accounts configuration&#8230;</string>
+    <string name="file_migration_ok_finished">Finished</string>
+    <string name="file_migration_failed_not_enough_space">ERROR: Not enough space</string>
+    <string name="file_migration_failed_not_writable">ERROR: File is not writable</string>
+    <string name="file_migration_failed_not_readable">ERROR: File is not readable</string>
+    <string name="file_migration_failed_dir_already_exists">ERROR: Nextcloud directory already exists</string>
+    <string name="file_migration_failed_while_coping">ERROR: While migrating</string>
+    <string name="file_migration_failed_while_updating_index">ERROR: While updating index</string>
+
+    <string name="file_migration_directory_already_exists">Data folder already exists, what to do?</string>
+    <string name="file_migration_override_data_folder">Override</string>
+    <string name="file_migration_use_data_folder">Use existing</string>
+
     <string name="prefs_category_accounts">Accounts</string>
     <string name="prefs_add_account">Add account</string>
     <string name="drawer_manage_accounts">Manage accounts</string>
@@ -422,6 +444,8 @@
     <string name="pref_behaviour_entries_keep_file">kept in original folder</string>
     <string name="pref_behaviour_entries_move">moved to app folder</string>
     <string name="pref_behaviour_entries_delete_file">deleted</string>
+    <string name="prefs_storage_path">Storage path</string>
+    <string name="prefs_common">Common</string>
 
     <string name="share_dialog_title">Sharing</string>
     <string name="share_file">Share %1$s</string>
@@ -497,4 +521,8 @@
         <item quantity="other">%d selected</item>
     </plurals>
 
+    <string name="storage_description_default">Default</string>
+    <string name="storage_description_sd_no">SD card %1$d</string>
+    <string name="storage_description_unknown">Unknown</string>
+
 </resources>

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

@@ -419,7 +419,6 @@
     <string name="pref_behaviour_entries_keep_file">dejado en la carpeta original</string>
     <string name="pref_behaviour_entries_move">movido a la carpeta apps</string>
     <string name="pref_behaviour_entries_delete_file">borrado</string>
-
     <string name="share_dialog_title">Compartiendo</string>
     <string name="share_file">Compartir %1$s</string>
     <string name="share_with_user_section_title">Compartir con usuarios y grupos</string>
@@ -482,4 +481,4 @@
         <item quantity="other">%d seleccionados</item>
     </plurals>
 
-</resources>
+    </resources>

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

@@ -28,6 +28,7 @@
     <string name="prefs_accounts">Comptes</string>
     <string name="prefs_manage_accounts">Gestion des comptes</string>
     <string name="prefs_passcode">Code de sécurité</string>
+    <string name="prefs_show_hidden_files">Afficher les fichiers cachés</string>
     <string name="prefs_instant_upload">Téléversement immédiat des photos</string>
     <string name="prefs_instant_upload_summary">Téléverser immédiatement les photos prises par la caméra</string>
     <string name="prefs_instant_video_upload">Téléversement immédiat des vidéos</string>
@@ -356,6 +357,15 @@ La suppression est irréversible. </string>
     <string name="uploader_upload_forbidden_permissions">de téléverser dans ce dossier</string>
     <string name="downloader_download_file_not_found">Ce fichier n’est plus disponible sur le serveur</string>
 
+    <string name="file_migration_finish_button">Terminer</string>
+    <string name="file_migration_ok_finished">Terminé</string>
+    <string name="file_migration_failed_not_enough_space">ERREUR : Pas assez d\'espace</string>
+    <string name="file_migration_failed_not_writable">ERREUR : Le fichier n\'est pas modifiable</string>
+    <string name="file_migration_failed_not_readable">ERREUR : Le fichier n\'est pas lisible</string>
+    <string name="file_migration_failed_dir_already_exists">ERREUR : Le répertoire Nextcloud existe déjà</string>
+    <string name="file_migration_failed_while_coping">ERREUR : Lors de la migration</string>
+    <string name="file_migration_failed_while_updating_index">ERREUR : Lors de la mise à jour de l\'index</string>
+
     <string name="prefs_category_accounts">Comptes</string>
     <string name="prefs_add_account">Ajouter un compte</string>
     <string name="drawer_manage_accounts">Gestion des comptes</string>
@@ -422,7 +432,6 @@ La suppression est irréversible. </string>
     <string name="pref_behaviour_entries_keep_file">gardé dans le dossier original</string>
     <string name="pref_behaviour_entries_move">déplacé vers le dossier de l\'application</string>
     <string name="pref_behaviour_entries_delete_file">Supprimé</string>
-
     <string name="share_dialog_title">Partage</string>
     <string name="share_file">Partager %1$s</string>
     <string name="share_with_user_section_title">Partager avec des utilisateurs et des groupes</string>
@@ -500,4 +509,7 @@ ou</string>
         <item quantity="other">%d sélectionnés</item>
     </plurals>
 
+    <string name="storage_description_sd_no">Carte SD %1$d</string>
+    <string name="storage_description_unknown">Inconnu</string>
+
 </resources>

+ 28 - 0
res/values-hu-rHU/strings.xml

@@ -355,6 +355,28 @@
     <string name="uploader_upload_forbidden_permissions">ebbe a mappába feltölteni</string>
     <string name="downloader_download_file_not_found">A fájl már nem érhető el a szerveren</string>
 
+    <string name="file_migration_dialog_title">Tároló útvonal frissítés</string>
+    <string name="file_migration_finish_button">Befejez</string>
+    <string name="file_migration_preparing">Migráció előkészítése&#8230;</string>
+    <string name="file_migration_checking_destination">Cél ellenőrzése&#8230;</string>
+    <string name="file_migration_saving_accounts_configuration">Fiók beállítások mentése&#8230;</string>
+    <string name="file_migration_waiting_for_unfinished_sync">Várakozás a befejezetlen szinkronizációkra&#8230;</string>
+    <string name="file_migration_migrating">Adatok áthelyezése&#8230;</string>
+    <string name="file_migration_updating_index">Index frissítése&#8230;</string>
+    <string name="file_migration_cleaning">Tisztítás&#8230;</string>
+    <string name="file_migration_restoring_accounts_configuration">Fiók beállítások visszaállítása&#8230;</string>
+    <string name="file_migration_ok_finished">Kész</string>
+    <string name="file_migration_failed_not_enough_space">HIBA: Nincs elég hely</string>
+    <string name="file_migration_failed_not_writable">HIBA: A fájl nem írható</string>
+    <string name="file_migration_failed_not_readable">HIBA: A fájl nem olvasható</string>
+    <string name="file_migration_failed_dir_already_exists">HIBA: A Nextcloud könyvtár már létezik</string>
+    <string name="file_migration_failed_while_coping">HIBA: A migráció közben</string>
+    <string name="file_migration_failed_while_updating_index">HIBA: Az Index frissítése közben</string>
+
+    <string name="file_migration_directory_already_exists">Az adat mappa már létezik, mi tegyünk?</string>
+    <string name="file_migration_override_data_folder">Felülírás</string>
+    <string name="file_migration_use_data_folder">Létező használata</string>
+
     <string name="prefs_category_accounts">Fiókok</string>
     <string name="prefs_add_account">Fiók hozzáadása</string>
     <string name="drawer_manage_accounts">Fiókok kezelése</string>
@@ -421,6 +443,8 @@
     <string name="pref_behaviour_entries_keep_file">megtartani az eredeti mappában</string>
     <string name="pref_behaviour_entries_move">áthelyezve az alkalmazás mappába</string>
     <string name="pref_behaviour_entries_delete_file">törölt</string>
+    <string name="prefs_storage_path">Tároló útvonal</string>
+    <string name="prefs_common">Általános</string>
 
     <string name="share_dialog_title">Megosztás</string>
     <string name="share_file">%1$s megosztása</string>
@@ -497,4 +521,8 @@ vagy</string>
         <item quantity="other">%d kiválasztott</item>
     </plurals>
 
+    <string name="storage_description_default">Alapértelmezett</string>
+    <string name="storage_description_sd_no">SD kártya %1$d</string>
+    <string name="storage_description_unknown">Ismeretlen</string>
+
 </resources>

+ 1 - 1
res/values-id/strings.xml

@@ -455,4 +455,4 @@
         <item quantity="other">%d dipilih</item>
     </plurals>
 
-</resources>
+    </resources>

+ 1 - 2
res/values-is/strings.xml

@@ -391,7 +391,6 @@
     <string name="pref_behaviour_entries_keep_file">áfram í upprunalegri möppu</string>
     <string name="pref_behaviour_entries_move">færð í forritsmöppu</string>
     <string name="pref_behaviour_entries_delete_file">eytt</string>
-
     <string name="share_dialog_title">Deiling</string>
     <string name="share_file">Deila %1$s</string>
     <string name="share_with_user_section_title">Deila með notendum eða hópum</string>
@@ -462,4 +461,4 @@
         <item quantity="other">%d valið</item>
     </plurals>
 
-</resources>
+    </resources>

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

@@ -356,6 +356,28 @@
     <string name="uploader_upload_forbidden_permissions">per caricare in questa cartella</string>
     <string name="downloader_download_file_not_found">Il file non è più disponibile sul server</string>
 
+    <string name="file_migration_dialog_title">Aggiornamento del percorso di archiviazione</string>
+    <string name="file_migration_finish_button">Fine</string>
+    <string name="file_migration_preparing">Preparazione della migrazione&#8230;</string>
+    <string name="file_migration_checking_destination">Controllo della destinazione&#8230;</string>
+    <string name="file_migration_saving_accounts_configuration">Salvataggio della configurazione degli account&#8230;</string>
+    <string name="file_migration_waiting_for_unfinished_sync">In attesa del completamento delle sincronizzazioni&#8230;</string>
+    <string name="file_migration_migrating">Spostamento dei dati&#8230;</string>
+    <string name="file_migration_updating_index">Aggiornamento dell\'indice&#8230;</string>
+    <string name="file_migration_cleaning">Pulizia&#8230;</string>
+    <string name="file_migration_restoring_accounts_configuration">Ripristino della configurazione degli account&#8230;</string>
+    <string name="file_migration_ok_finished">Fine</string>
+    <string name="file_migration_failed_not_enough_space">ERRORE: spazio libero insufficiente</string>
+    <string name="file_migration_failed_not_writable">ERRORE: il file non è scrivibile</string>
+    <string name="file_migration_failed_not_readable">ERRORE: il file non è leggibile</string>
+    <string name="file_migration_failed_dir_already_exists">ERRORE: la cartella di Nextcloud esiste già</string>
+    <string name="file_migration_failed_while_coping">ERRORE: durante la migrazione</string>
+    <string name="file_migration_failed_while_updating_index">ERRORE: durante l\'aggiornamento dell\'indice</string>
+
+    <string name="file_migration_directory_already_exists">La cartella dei dati esiste già, cosa vuoi fare?</string>
+    <string name="file_migration_override_data_folder">Sovrascrivi</string>
+    <string name="file_migration_use_data_folder">Utilizza quella esistente</string>
+
     <string name="prefs_category_accounts">Account</string>
     <string name="prefs_add_account">Aggiungi account</string>
     <string name="drawer_manage_accounts">Gestisci account</string>
@@ -422,6 +444,8 @@
     <string name="pref_behaviour_entries_keep_file">lasciato nella cartella originale</string>
     <string name="pref_behaviour_entries_move">spostato nella cartella dell\'applicazione</string>
     <string name="pref_behaviour_entries_delete_file">eliminato</string>
+    <string name="prefs_storage_path">Percorso di archiviazione</string>
+    <string name="prefs_common">Comune</string>
 
     <string name="share_dialog_title">Condivisione</string>
     <string name="share_file">Condividi %1$s</string>
@@ -500,4 +524,8 @@ o</string>
         <item quantity="other">%d selezionati</item>
     </plurals>
 
+    <string name="storage_description_default">Predefinito</string>
+    <string name="storage_description_sd_no">Scheda SD %1$d</string>
+    <string name="storage_description_unknown">Sconosciuto</string>
+
 </resources>

+ 1 - 2
res/values-ko/strings.xml

@@ -400,7 +400,6 @@
     <string name="pref_behaviour_entries_keep_file">원래 폴더에 유지</string>
     <string name="pref_behaviour_entries_move">앱 폴더로 이동되었습니다.</string>
     <string name="pref_behaviour_entries_delete_file">삭제됨</string>
-
     <string name="share_dialog_title">공유</string>
     <string name="share_file">공유 %1$s</string>
     <string name="share_with_user_section_title">유저와 그룹에 공유하기</string>
@@ -467,4 +466,4 @@
         <item quantity="other">%d 선택</item>
     </plurals>
 
-</resources>
+    </resources>

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

@@ -356,6 +356,25 @@
     <string name="uploader_upload_forbidden_permissions">å laste opp i denne mappen</string>
     <string name="downloader_download_file_not_found">Filen finnes ikke på tjeneren lenger</string>
 
+    <string name="file_migration_finish_button">Fullfør</string>
+    <string name="file_migration_preparing">Forebereder migrering&#8230;</string>
+    <string name="file_migration_checking_destination">Sjekker mål&#8230;</string>
+    <string name="file_migration_saving_accounts_configuration">Lagrer kontokonfigurasjon&#8230;</string>
+    <string name="file_migration_waiting_for_unfinished_sync">Venter på uferdig synkronisering&#8230;</string>
+    <string name="file_migration_migrating">Flytter data&#8230;</string>
+    <string name="file_migration_updating_index">Oppdaterer index&#8230;</string>
+    <string name="file_migration_cleaning">Rydder&#8230;</string>
+    <string name="file_migration_ok_finished">Fullført</string>
+    <string name="file_migration_failed_not_enough_space">FEIL: Ikke nok plass</string>
+    <string name="file_migration_failed_not_writable">FEIL: Filen er skrivebeskyttet</string>
+    <string name="file_migration_failed_not_readable">FEIL: er ikke lesbar</string>
+    <string name="file_migration_failed_dir_already_exists">FEIL: Nextcloudmappen finnes allerede</string>
+    <string name="file_migration_failed_while_coping">FEIL: Under migrering</string>
+    <string name="file_migration_failed_while_updating_index">FEIL: Under oppdatering av indeks</string>
+
+    <string name="file_migration_override_data_folder">Overstyr</string>
+    <string name="file_migration_use_data_folder">Bruk eksisterende</string>
+
     <string name="prefs_category_accounts">Kontoer</string>
     <string name="prefs_add_account">Legg til en konto</string>
     <string name="drawer_manage_accounts">Håndter kontoer</string>
@@ -422,6 +441,8 @@
     <string name="pref_behaviour_entries_keep_file">beholdt i opprinnelig mappe</string>
     <string name="pref_behaviour_entries_move">flyttet til app-mappe</string>
     <string name="pref_behaviour_entries_delete_file">slettet</string>
+    <string name="prefs_storage_path">Lagrings-sti</string>
+    <string name="prefs_common">Felles</string>
 
     <string name="share_dialog_title">Deling</string>
     <string name="share_file">Del %1$s</string>
@@ -500,4 +521,8 @@ eller</string>
         <item quantity="other">%d valgte</item>
     </plurals>
 
+    <string name="storage_description_default">Standard</string>
+    <string name="storage_description_sd_no">SD kort %1$d</string>
+    <string name="storage_description_unknown">Ukjent</string>
+
 </resources>

+ 31 - 3
res/values-nl/strings.xml

@@ -70,7 +70,7 @@ Download hier: %2$s</string>
     <string name="uploader_wrn_no_account_quit_btn_text">Afsluiten</string>
     <string name="uploader_error_title_no_file_to_upload">Niets te uploaden</string>
     <string name="uploader_error_message_received_piece_of_text">%1$s kan niet een stuk tekst als bestand uploaden.</string>
-    <string name="uploader_error_message_no_file_to_upload">Ontvangen data bevat geen geldig bestand.</string>
+    <string name="uploader_error_message_no_file_to_upload">Ontvangen gegevens bevat geen geldig bestand.</string>
     <string name="uploader_error_title_file_cannot_be_uploaded">Bestand kan niet worden geüpload</string>
     <string name="uploader_error_message_read_permission_not_granted">%1$s is niet toegestaan om een ontvangen bestand te lezen</string>
     <string name="uploader_error_message_source_file_not_found">Het te uploaden bestand is hier niet. Controleer of het bestand wel bestaat.</string>
@@ -359,6 +359,28 @@ Hieronder staan de lokale bestanden en de externe bestanden in %5$s waar ze naar
     <string name="uploader_upload_forbidden_permissions">om dit bestand in deze map te uploaden</string>
     <string name="downloader_download_file_not_found">Dit bestand is niet langer beschikbaar op de server</string>
 
+    <string name="file_migration_dialog_title">Opslagpad bijwerken</string>
+    <string name="file_migration_finish_button">Afgerond</string>
+    <string name="file_migration_preparing">Voorbereiden van migratie&#8230;</string>
+    <string name="file_migration_checking_destination">Doelmap controleren&#8230;</string>
+    <string name="file_migration_saving_accounts_configuration">Account configuratie opslaan&#8230;</string>
+    <string name="file_migration_waiting_for_unfinished_sync">Wachten op onvoltooide synchronisaties&#8230;</string>
+    <string name="file_migration_migrating">Gegevens verplaatsen&#8230;</string>
+    <string name="file_migration_updating_index">Index bijwerken&#8230;</string>
+    <string name="file_migration_cleaning">Schoonmaak&#8230;</string>
+    <string name="file_migration_restoring_accounts_configuration">Account configuratie herstellen&#8230;</string>
+    <string name="file_migration_ok_finished">Afgerond</string>
+    <string name="file_migration_failed_not_enough_space">ERROR: Niet genoeg ruimte</string>
+    <string name="file_migration_failed_not_writable">ERROR: Bestand niet beschrijfbaar</string>
+    <string name="file_migration_failed_not_readable">ERROR: Bestand niet berijkbaar</string>
+    <string name="file_migration_failed_dir_already_exists">ERROR: Nextcloud map bestaat al</string>
+    <string name="file_migration_failed_while_coping">ERROR: Tijdens migratie</string>
+    <string name="file_migration_failed_while_updating_index">ERROR: Tijdens bijwerken index</string>
+
+    <string name="file_migration_directory_already_exists">Folder bestaat al, wat te doen?</string>
+    <string name="file_migration_override_data_folder">Overschrijven</string>
+    <string name="file_migration_use_data_folder">Bestaande gebruiken</string>
+
     <string name="prefs_category_accounts">Accounts</string>
     <string name="prefs_add_account">Toevoegen account</string>
     <string name="drawer_manage_accounts">Beheren accounts</string>
@@ -368,7 +390,7 @@ Hieronder staan de lokale bestanden en de externe bestanden in %5$s waar ze naar
 	<string name="log_send_history_button">Verstuur geschiedenis</string>
 	<string name="log_send_no_mail_app">Geen applicatie gevonden voor het versturen van de logs. Installeer een mail applicatie.</string>
 	<string name="log_send_mail_subject">%1$s Android app logs</string>
-	<string name="log_progress_dialog_text">Laden data …</string>
+	<string name="log_progress_dialog_text">gegevens laden &#8230;</string>
 
 	<string name="saml_authentication_required_text">Authenticatie vereist</string>
 	<string name="saml_authentication_wrong_pass">Onjuist wachtwoord</string>
@@ -425,6 +447,8 @@ Hieronder staan de lokale bestanden en de externe bestanden in %5$s waar ze naar
     <string name="pref_behaviour_entries_keep_file">bewaard in originele map</string>
     <string name="pref_behaviour_entries_move">verplaatst naar app map</string>
     <string name="pref_behaviour_entries_delete_file">verwijderd</string>
+    <string name="prefs_storage_path">Opslagpad</string>
+    <string name="prefs_common">Gemeenschappelijk</string>
 
     <string name="share_dialog_title">Delen</string>
     <string name="share_file">Deel %1$s</string>
@@ -468,7 +492,7 @@ Neem contact op met je beheerder</string>
 
     <string name="manage_space_title">Beheer ruimte</string>
     <string name="manage_space_description">Instellingen, database en servercertificaten van %1$s\'s data zullen permanent worden verwijderd. \n\nGedownloade bestanden blijven onaangeroerd.\n\nDit proces kan even duren.</string>
-    <string name="manage_space_clear_data">Verwijder data</string>
+    <string name="manage_space_clear_data">Gegevens verwijderen</string>
     <string name="manage_space_error">Sommige bestanden konden niet worden verwijderd</string>
 
     <string name="permission_storage_access">Aanvullende permssies vereist voor het uploaden en downloaden van bestanden.</string>
@@ -502,4 +526,8 @@ of</string>
         <item quantity="other">%d geselecteerd</item>
     </plurals>
 
+    <string name="storage_description_default">Standaard</string>
+    <string name="storage_description_sd_no">SD kaart %1$d</string>
+    <string name="storage_description_unknown">Onbekend</string>
+
 </resources>

+ 24 - 1
res/values-pl/strings.xml

@@ -356,6 +356,27 @@
     <string name="uploader_upload_forbidden_permissions">do wgrania tego folderu</string>
     <string name="downloader_download_file_not_found">Ten plik nie jest już dostępny na serwerze</string>
 
+    <string name="file_migration_finish_button">Koniec</string>
+    <string name="file_migration_preparing">Przygotowanie do migracji&#8230;</string>
+    <string name="file_migration_checking_destination">Sprawdzanie docelowe&#8230;</string>
+    <string name="file_migration_saving_accounts_configuration">Zapisywanie konfiguracji konta&#8230;</string>
+    <string name="file_migration_waiting_for_unfinished_sync">Oczekiwanie na niedokończone synchronizacje&#8230;</string>
+    <string name="file_migration_migrating">Przenoszenie danych&#8230;</string>
+    <string name="file_migration_updating_index">Aktualizacja indeksa&#8230;</string>
+    <string name="file_migration_cleaning">Czyszczenie&#8230;</string>
+    <string name="file_migration_restoring_accounts_configuration">Przywracanie konfiguracji konta&#8230;</string>
+    <string name="file_migration_ok_finished">Skończone</string>
+    <string name="file_migration_failed_not_enough_space">BŁĄD: Za mało miejsca</string>
+    <string name="file_migration_failed_not_writable">BŁĄD: Plik nie jest zapisywalny</string>
+    <string name="file_migration_failed_not_readable">BŁĄD: Nie można odczytać pliku</string>
+    <string name="file_migration_failed_dir_already_exists">BŁĄD: Katalog Nextcloud już istnieje</string>
+    <string name="file_migration_failed_while_coping">BŁĄD: Podczas migracji</string>
+    <string name="file_migration_failed_while_updating_index">BŁĄD: Podczas aktualizacji indeksu</string>
+
+    <string name="file_migration_directory_already_exists">Folder danych już istnieje, co zrobić?</string>
+    <string name="file_migration_override_data_folder">Nadpisanie</string>
+    <string name="file_migration_use_data_folder">Użyj istniejącego</string>
+
     <string name="prefs_category_accounts">Konta</string>
     <string name="prefs_add_account">Dodaj konto</string>
     <string name="drawer_manage_accounts">Zarządzaj kontami</string>
@@ -422,7 +443,6 @@
     <string name="pref_behaviour_entries_keep_file">zachowany w oryginalnym folderze</string>
     <string name="pref_behaviour_entries_move">przeniesiony do folderu aplikacji</string>
     <string name="pref_behaviour_entries_delete_file">usunięty</string>
-
     <string name="share_dialog_title">Udostępnianie</string>
     <string name="share_file">Współdziel %1$s</string>
     <string name="share_with_user_section_title">Współdziel z użytkownikami i grupami</string>
@@ -497,4 +517,7 @@
         <item quantity="other">%d zaznaczonych</item>
     </plurals>
 
+    <string name="storage_description_sd_no">karta SD %1$d</string>
+    <string name="storage_description_unknown">Nieznany</string>
+
 </resources>

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

@@ -28,6 +28,7 @@
     <string name="prefs_accounts">Contas</string>
     <string name="prefs_manage_accounts">Gerenciar contas</string>
     <string name="prefs_passcode">Bloqueio com senha</string>
+    <string name="prefs_show_hidden_files">Mostrar arquivos escondidos</string>
     <string name="prefs_instant_upload">Envio instantâneo de imagens</string>
     <string name="prefs_instant_upload_summary">Envia instantaneamente as fotos tiradas com a câmera</string>
     <string name="prefs_instant_video_upload">Envio instantâneo de vídeos</string>
@@ -355,6 +356,28 @@
     <string name="uploader_upload_forbidden_permissions">para enviar para esta pasta</string>
     <string name="downloader_download_file_not_found">Este arquivo não mais está disponível neste servidor</string>
 
+    <string name="file_migration_dialog_title">Atualizando caminho do storage</string>
+    <string name="file_migration_finish_button">Finalizado</string>
+    <string name="file_migration_preparing">Preparando para migração&#8230;</string>
+    <string name="file_migration_checking_destination">Verificando destino&#8230;</string>
+    <string name="file_migration_saving_accounts_configuration">Salvando configuração de contas&#8230;</string>
+    <string name="file_migration_waiting_for_unfinished_sync">Aguardando por sincronismo não-finalizado&#8230;</string>
+    <string name="file_migration_migrating">Movendo dados&#8230;</string>
+    <string name="file_migration_updating_index">Atualizando index&#8230;</string>
+    <string name="file_migration_cleaning">Limpando&#8230;</string>
+    <string name="file_migration_restoring_accounts_configuration">Restaurando configurações de contas&#8230;</string>
+    <string name="file_migration_ok_finished">Finalizado</string>
+    <string name="file_migration_failed_not_enough_space">ERRO: Espaço Insuficiente</string>
+    <string name="file_migration_failed_not_writable">ERRO: Arquivo não permite gravação</string>
+    <string name="file_migration_failed_not_readable">ERRO: Arquivo não permite leitura</string>
+    <string name="file_migration_failed_dir_already_exists">ERRO: diretório ou pasta já existe</string>
+    <string name="file_migration_failed_while_coping">ERRO: Durante a Migração</string>
+    <string name="file_migration_failed_while_updating_index">ERRO: Durante atualização de indice</string>
+
+    <string name="file_migration_directory_already_exists">Pasta de dados já existe, o que fazer?</string>
+    <string name="file_migration_override_data_folder">Sobrescrever</string>
+    <string name="file_migration_use_data_folder">Usar existente</string>
+
     <string name="prefs_category_accounts">Contas</string>
     <string name="prefs_add_account">Adicionar uma conta</string>
     <string name="drawer_manage_accounts">Gerenciar contas</string>
@@ -421,6 +444,8 @@
     <string name="pref_behaviour_entries_keep_file">mantido na pasta original</string>
     <string name="pref_behaviour_entries_move">movido para a pasta app</string>
     <string name="pref_behaviour_entries_delete_file">excluído</string>
+    <string name="prefs_storage_path">Caminho do storage</string>
+    <string name="prefs_common">Comum</string>
 
     <string name="share_dialog_title">Compartilhamento</string>
     <string name="share_file">Compartilhar %1$s</string>
@@ -498,4 +523,8 @@
         <item quantity="other">%d selecionados</item>
     </plurals>
 
+    <string name="storage_description_default">Padrão</string>
+    <string name="storage_description_sd_no">Cartão SD %1$d</string>
+    <string name="storage_description_unknown">Desconhecido</string>
+
 </resources>

+ 2 - 2
res/values-ru/strings.xml

@@ -28,6 +28,7 @@
     <string name="prefs_accounts">Аккаунты</string>
     <string name="prefs_manage_accounts">Управление аккаунтами</string>
     <string name="prefs_passcode">Блокировка кодом</string>
+    <string name="prefs_show_hidden_files">Показать скрытые файлы</string>
     <string name="prefs_instant_upload">Автозагрузка изображений</string>
     <string name="prefs_instant_upload_summary">Автоматически загружать изображения, сделанные камерой</string>
     <string name="prefs_instant_video_upload">Автозагрузка видео</string>
@@ -422,7 +423,6 @@
     <string name="pref_behaviour_entries_keep_file">оставлен в исходной папке</string>
     <string name="pref_behaviour_entries_move">перемещен в папку приложения</string>
     <string name="pref_behaviour_entries_delete_file">Удалён</string>
-
     <string name="share_dialog_title">Общий доступ</string>
     <string name="share_file">Поделиться %1$s</string>
     <string name="share_with_user_section_title">Поделиться с пользователями и группами</string>
@@ -495,4 +495,4 @@
         <item quantity="other">%d выбрано</item>
     </plurals>
 
-</resources>
+    </resources>

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

@@ -420,7 +420,6 @@
     <string name="pref_behaviour_entries_keep_file">ohrani v izvorni mapi</string>
     <string name="pref_behaviour_entries_move">premakni v mapo programa</string>
     <string name="pref_behaviour_entries_delete_file">pobrisano</string>
-
     <string name="share_dialog_title">Souporaba</string>
     <string name="share_file">Omogoči souporabo %1$s</string>
     <string name="share_with_user_section_title">Omogoči souporabo s skupino ali z uporabnikom</string>
@@ -492,4 +491,4 @@
         <item quantity="other">%d izbranih</item>
     </plurals>
 
-</resources>
+    </resources>

+ 1 - 2
res/values-sq/strings.xml

@@ -417,7 +417,6 @@
     <string name="pref_behaviour_entries_keep_file">mbajtur në dosjen origjinale</string>
     <string name="pref_behaviour_entries_move">u kalua te dosja e aplikacionit</string>
     <string name="pref_behaviour_entries_delete_file">të fshira</string>
-
     <string name="share_dialog_title">Ndarje me të tjerët</string>
     <string name="share_file">Ndajeni %1$s</string>
     <string name="share_with_user_section_title">Ndajeni me përdorues dhe grupe</string>
@@ -491,4 +490,4 @@
         <item quantity="other">%d të përzgjedhura</item>
     </plurals>
 
-</resources>
+    </resources>

+ 5 - 6
res/values-sv/strings.xml

@@ -17,7 +17,7 @@
     <string name="menu_item_sort_by_date">Nyast - Äldst</string>
     <string name="menu_item_sort_by_size">Störst - Minst</string>
     <string name="drawer_item_all_files">Alla filer</string>
-    <string name="drawer_item_on_device">På enheten</string>
+    <string name="drawer_item_on_device">Filer på enheten</string>
     <string name="drawer_item_settings">Inställningar</string>
     <string name="drawer_item_uploads_list">Uppladdningar</string>
     <string name="drawer_quota">%1$s av %2$s använt</string>
@@ -313,7 +313,7 @@
     <string name="error__upload__local_file_not_copied">%1$s kunde inte kopieras till %2$s lokal mapp</string>
     <string name="prefs_instant_upload_path_title">Uppladdningssökväg</string>
     <string name="prefs_instant_upload_path_use_subfolders_title">Använd undermappar</string>
-    <string name="prefs_instant_upload_path_use_subfolders_summary">Spara i undermappar baserad på år och månad</string>
+    <string name="prefs_instant_upload_path_use_subfolders_summary">Spara i undermappar baserat på år och månad</string>
 
 	<string name="share_link_no_support_share_api">Ledsen, delning är inte aktiverat på din server. Vänligen kontakta din
 		administratör.</string>
@@ -417,8 +417,7 @@
 
     <string name="pref_behaviour_entries_keep_file">behållas i orginalmapp</string>
     <string name="pref_behaviour_entries_move">flyttas till Nextcloudmapp</string>
-    <string name="pref_behaviour_entries_delete_file">raderad</string>
-
+    <string name="pref_behaviour_entries_delete_file">raderas</string>
     <string name="share_dialog_title">Dela</string>
     <string name="share_file">Dela %1$s</string>
     <string name="share_with_user_section_title">Dela med användare och grupper</string>
@@ -450,7 +449,7 @@
     <string name="edit_share_unshare">Sluta dela</string>
     <string name="edit_share_done">färdig</string>
 
-    <string name="action_retry_uploads">Återuppladdningsförsök misslyckades</string>
+    <string name="action_retry_uploads">Försök ladda upp misslyckade igen</string>
     <string name="action_clear_failed_uploads">Rensa misslyckade</string>
     <string name="action_clear_successful_uploads">Rensa lyckade</string>
     <string name="action_clear_finished_uploads">Rensa alla färdigställda</string>
@@ -470,7 +469,7 @@
     <string name="uploads_view_upload_status_waiting_for_charging">Väntar på att enheten ska laddas</string>
     <string name="actionbar_search">Sök</string>
     <string name="learn_more">Lär dig mer</string>
-    <string name="drawer_participate">Delta</string>
+    <string name="drawer_participate">Hjälp oss att bli bättre</string>
     <string name="participate_testing_headline">Hjälp oss att testa</string>
     <string name="participate_testing_bug_text">Har du hittat en bugg? Är det något som är fel?</string>
     <string name="participate_testing_report_text">Rapportera ett problem på Github</string>

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

@@ -470,4 +470,4 @@
         <item quantity="other">%d seçili</item>
     </plurals>
 
-</resources>
+    </resources>

+ 1 - 2
res/values-zh-rTW/strings.xml

@@ -421,7 +421,6 @@
     <string name="pref_behaviour_entries_keep_file">保留在原本的資料夾</string>
     <string name="pref_behaviour_entries_move">移動到應用程式資料夾</string>
     <string name="pref_behaviour_entries_delete_file">已刪除</string>
-
     <string name="share_dialog_title">分享</string>
     <string name="share_file">分享 %1$s</string>
     <string name="share_with_user_section_title">分享給其他使用者或群組</string>
@@ -496,4 +495,4 @@
         <item quantity="other">%d 已選</item>
     </plurals>
 
-</resources>
+    </resources>

+ 8 - 4
src/com/owncloud/android/MainApp.java

@@ -42,6 +42,10 @@ import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.services.observer.SyncedFolderObserverService;
 import com.owncloud.android.ui.activity.Preferences;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 
 /**
  * Main Application of the project
@@ -67,17 +71,17 @@ public class MainApp extends Application {
     private static boolean mOnlyOnDevice = false;
 
     private static SyncedFolderObserverService mObserverService;
+
     @SuppressWarnings("unused")
     private boolean mBound;
 
-    
-    public void onCreate(){
+    @SuppressFBWarnings("ST")    public void onCreate(){
         super.onCreate();
         MainApp.mContext = getApplicationContext();
 
         SharedPreferences appPrefs =
                 PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
-        MainApp.storagePath = appPrefs.getString(Preferences.Keys.STORAGE_PATH, Environment.
+        MainApp.storagePath = appPrefs.getString(Preferences.PreferenceKeys.STORAGE_PATH, Environment.
                               getExternalStorageDirectory().getAbsolutePath());
 
         boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
@@ -210,7 +214,7 @@ public class MainApp extends Application {
         mOnlyOnDevice = state;
     }
 
-    public static boolean getOnlyOnDevice(){
+    public static boolean isOnlyOnDevice(){
         return mOnlyOnDevice;
     }
 

+ 3 - 6
src/com/owncloud/android/authentication/AccountAuthenticator.java

@@ -87,8 +87,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
                 validateAccountType(accountType);
             } catch (AuthenticatorException e) {
                 Log_OC.e(TAG, "Failed to validate account type " + accountType + ": "
-                        + e.getMessage());
-                e.printStackTrace();
+                        + e.getMessage(), e);
                 return e.getFailureBundle();
             }
             
@@ -133,8 +132,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
             validateAccountType(account.type);
         } catch (AuthenticatorException e) {
             Log_OC.e(TAG, "Failed to validate account type " + account.type + ": "
-                    + e.getMessage());
-            e.printStackTrace();
+                    + e.getMessage(), e);
             return e.getFailureBundle();
         }
         Intent intent = new Intent(mContext, AuthenticatorActivity.class);
@@ -169,8 +167,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
             validateAuthTokenType(authTokenType);
         } catch (AuthenticatorException e) {
             Log_OC.e(TAG, "Failed to validate account type " + account.type + ": "
-                    + e.getMessage());
-            e.printStackTrace();
+                    + e.getMessage(), e);
             return e.getFailureBundle();
         }
         

+ 7 - 8
src/com/owncloud/android/authentication/AccountUtils.java

@@ -119,7 +119,7 @@ public class AccountUtils {
      */
     public static String getAccountUsername(String accountName) {
         if (accountName != null) {
-            return accountName.substring(0, accountName.lastIndexOf("@"));
+            return accountName.substring(0, accountName.lastIndexOf('@'));
         } else {
             return null;
         }
@@ -135,8 +135,9 @@ public class AccountUtils {
         Account[] ocAccounts = AccountManager.get(context).getAccountsByType(
                 MainApp.getAccountType());
         for (Account account : ocAccounts) {
-            if(account.name.equals(accountName))
+            if(account.name.equals(accountName)) {
                 return account;
+            }
         }
         return null;
     }
@@ -241,15 +242,13 @@ public class AccountUtils {
                         );
 
                         // copy type of authentication
-                        String isSamlStr = accountMgr.getUserData(account, Constants.KEY_SUPPORTS_SAML_WEB_SSO);
-                        boolean isSaml = "TRUE".equals(isSamlStr);
-                        if (isSaml) {
+                        final String isSamlStr = accountMgr.getUserData(account, Constants.KEY_SUPPORTS_SAML_WEB_SSO);
+                        if (Boolean.parseBoolean(isSamlStr)) {
                             accountMgr.setUserData(newAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE");
                         }
 
-                        String isOauthStr = accountMgr.getUserData(account, Constants.KEY_SUPPORTS_OAUTH2);
-                        boolean isOAuth = "TRUE".equals(isOauthStr);
-                        if (isOAuth) {
+                        final String isOauthStr = accountMgr.getUserData(account, Constants.KEY_SUPPORTS_OAUTH2);
+                        if (Boolean.parseBoolean(isOauthStr)) {
                             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

+ 26 - 31
src/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -91,7 +91,7 @@ import com.owncloud.android.ui.dialog.SamlWebViewDialog;
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener;
 import com.owncloud.android.utils.DisplayUtils;
-
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.security.cert.X509Certificate;
 import java.util.Map;
 
@@ -142,6 +142,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     private static final String KEY_ASYNC_TASK_IN_PROGRESS = "AUTH_IN_PROGRESS";
     public static final String PROTOCOL_SUFFIX = "://";
     public static final String LOGIN_URL_DATA_KEY_VALUE_SEPARATOR = ":";
+    private static final String HTTPS_PROTOCOL = "https://";
+    private static final String HTTP_PROTOCOL = "http://";
 
     /// parameters from EXTRAs in starter Intent
     private byte mAction;
@@ -167,7 +169,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 
     private boolean mServerIsChecked = false;
     private boolean mServerIsValid = false;
-    private boolean mPendingAutoCheck = false;
 
     private GetServerInfoOperation.ServerInfo mServerInfo = new GetServerInfoOperation.ServerInfo();
 
@@ -408,11 +409,11 @@ 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://");
+                mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith(HTTPS_PROTOCOL);
                 mServerInfo.mVersion = AccountUtils.getServerVersion(mAccount);
             } else {
                 mServerInfo.mBaseUrl = getString(R.string.server_url).trim();
-                mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://");
+                mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith(HTTPS_PROTOCOL);
             }
         } else {
             mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT);
@@ -492,24 +493,16 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() {
             @Override
             public boolean onTouch(View view, MotionEvent event) {
-                if (event.getAction() == MotionEvent.ACTION_DOWN) {
-                    if (
-                            AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(
-                                    MainApp.getAccountType()
-                            ).equals(mAuthTokenType) &&
-                                    mHostUrlInput.hasFocus()
-                            ) {
-                        checkOcServer();
-                    }
+                if (event.getAction() == MotionEvent.ACTION_DOWN &&
+                        AccountTypeUtils
+                                .getAuthTokenTypeSamlSessionCookie(MainApp
+                                        .getAccountType()).equals(mAuthTokenType) &&
+                        mHostUrlInput.hasFocus()) {
+                    checkOcServer();
                 }
                 return false;
             }
         });
-
-
-        /// step 4 - mark automatic check to be started when OperationsService is ready
-        mPendingAutoCheck = (savedInstanceState == null &&
-                (mAction != ACTION_CREATE || checkHostUrl));
     }
 
 
@@ -1127,8 +1120,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
                 }
             }
 
-            if (success)
+            if (success) {
                 finish();
+            }
         } else {
             updateStatusIconFailUserName();
             showAuthStatus();
@@ -1197,14 +1191,15 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 
     // TODO remove, if possible
     private String normalizeUrl(String url, boolean sslWhenUnprefixed) {
+
         if (url != null && url.length() > 0) {
             url = url.trim();
-            if (!url.toLowerCase().startsWith("http://") &&
-                    !url.toLowerCase().startsWith("https://")) {
+            if (!url.toLowerCase().startsWith(HTTP_PROTOCOL) &&
+                    !url.toLowerCase().startsWith(HTTP_PROTOCOL)) {
                 if (sslWhenUnprefixed) {
-                    url = "https://" + url;
+                    url = HTTPS_PROTOCOL + url;
                 } else {
-                    url = "http://" + url;
+                    url = HTTP_PROTOCOL + url;
                 }
             }
 
@@ -1259,7 +1254,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 
             case OK_NO_SSL:
             case OK:
-                if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith("http://")) {
+                if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith(HTTP_PROTOCOL)) {
                     mServerStatusText = R.string.auth_connection_established;
                     mServerStatusIcon = R.drawable.ic_ok;
                 } else {
@@ -1340,7 +1335,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 
             case OK_NO_SSL:
             case OK:
-                if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith("http://")) {
+                if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith(HTTP_PROTOCOL)) {
                     mAuthStatusText = R.string.auth_connection_established;
                     mAuthStatusIcon = R.drawable.ic_ok;
                 } else {
@@ -1576,6 +1571,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
      *
      * TODO Decide how to name the OAuth accounts
      */
+    @SuppressFBWarnings("DMI")
     private boolean createAccount(RemoteOperationResult authResult) {
         /// create and save new ownCloud account
         boolean isOAuth = AccountTypeUtils.
@@ -1782,11 +1778,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             }
 
         } else if (actionId == EditorInfo.IME_ACTION_NEXT && inputField != null &&
-                inputField.equals(mHostUrlInput)) {
-            if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).
-                    equals(mAuthTokenType)) {
+                inputField.equals(mHostUrlInput) &&
+                AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).
+                        equals(mAuthTokenType)) {
                 checkOcServer();
-            }
         }
         return false;   // always return false to grant that the software keyboard is hidden anyway
     }
@@ -1847,7 +1842,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             mAuthToken = sessionCookie;
             getRemoteUserNameOperation(sessionCookie);
             Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG);
-            if (fd != null && fd instanceof DialogFragment) {
+            if (fd instanceof DialogFragment) {
                 Dialog d = ((DialogFragment) fd).getDialog();
                 if (d != null && d.isShowing()) {
                     d.dismiss();
@@ -1950,7 +1945,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 
     private void dismissDialog(String dialogTag) {
         Fragment frag = getSupportFragmentManager().findFragmentByTag(dialogTag);
-        if (frag != null && frag instanceof DialogFragment) {
+        if (frag instanceof DialogFragment) {
             DialogFragment dialog = (DialogFragment) frag;
             dialog.dismiss();
         }

+ 2 - 2
src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java

@@ -40,8 +40,8 @@ import java.lang.ref.WeakReference;
  */
 public class AuthenticatorAsyncTask  extends AsyncTask<Object, Void, RemoteOperationResult> {
 
-    private static String REMOTE_PATH = "/";
-    private static boolean SUCCESS_IF_ABSENT = false;
+    private static final String REMOTE_PATH = "/";
+    private static final boolean SUCCESS_IF_ABSENT = false;
 
     private Context mContext;
     private final WeakReference<OnAuthenticatorTaskListener> mListener;

+ 1 - 1
src/com/owncloud/android/authentication/PassCodeManager.java

@@ -43,7 +43,7 @@ public class PassCodeManager {
         // other activities may be exempted, if needed
     }
 
-    private static int PASS_CODE_TIMEOUT = 1000;
+    private static final int PASS_CODE_TIMEOUT = 1000;
         // keeping a "low" positive value is the easiest way to prevent the pass code is requested on rotations
 
     public static PassCodeManager mPassCodeManagerInstance = null;

File diff suppressed because it is too large
+ 182 - 259
src/com/owncloud/android/datamodel/FileDataStorageManager.java


+ 18 - 10
src/com/owncloud/android/datamodel/OCFile.java

@@ -30,7 +30,6 @@ import android.os.Build;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.support.v4.content.FileProvider;
-import android.webkit.MimeTypeMap;
 
 import com.owncloud.android.R;
 import com.owncloud.android.lib.common.network.WebdavUtils;
@@ -549,22 +548,31 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
 
     @Override
     public boolean equals(Object o) {
-        if (o instanceof OCFile) {
-            OCFile that = (OCFile) o;
-            if (that != null) {
-                return this.mId == that.mId;
-            }
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
         }
 
-        return false;
+        OCFile ocFile = (OCFile) o;
+
+        return mId == ocFile.mId && mParentId == ocFile.mParentId;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = (int) (mId ^ (mId >>> 32));
+        result = 31 * result + (int) (mParentId ^ (mParentId >>> 32));
+        return result;
     }
 
     @Override
     public String toString() {
         String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, " +
                 "parentId=%s, favorite=%s etag=%s]";
-        asString = String.format(asString, Long.valueOf(mId), getFileName(), mMimeType, isDown(),
-                mLocalPath, mRemotePath, Long.valueOf(mParentId), Boolean.valueOf(mFavorite),
+        asString = String.format(asString, mId, getFileName(), mMimeType, isDown(),
+                mLocalPath, mRemotePath, mParentId, mFavorite,
                 mEtag);
         return asString;
     }
@@ -638,7 +646,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
     }
 
     public boolean isInConflict() {
-        return mEtagInConflict != null && mEtagInConflict != "";
+        return mEtagInConflict != null && !mEtagInConflict.equals("");
     }
 
     public void setEtagInConflict(String etagInConflict) {

+ 40 - 37
src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java

@@ -57,6 +57,8 @@ import java.io.File;
 import java.io.InputStream;
 import java.lang.ref.WeakReference;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 /**
  * Manager for concurrent access to thumbnails cache.
  */
@@ -75,13 +77,13 @@ public class ThumbnailsCacheManager {
     private static final int mCompressQuality = 70;
     private static OwnCloudClient mClient = null;
 
-    public static Bitmap mDefaultImg = 
+    public static final Bitmap mDefaultImg =
             BitmapFactory.decodeResource(
                     MainApp.getAppContext().getResources(),
                     R.drawable.file_image
             );
 
-    public static Bitmap mDefaultVideo =
+    public static final Bitmap mDefaultVideo =
             BitmapFactory.decodeResource(
                     MainApp.getAppContext().getResources(),
                     R.drawable.file_movie
@@ -190,15 +192,17 @@ public class ThumbnailsCacheManager {
                                        Account account) {
             // Use a WeakReference to ensure the ImageView can be garbage collected
             mImageViewReference = new WeakReference<ImageView>(imageView);
-            if (storageManager == null)
+            if (storageManager == null) {
                 throw new IllegalArgumentException("storageManager must not be NULL");
+            }
             mStorageManager = storageManager;
             mAccount = account;
         }
 
         public ThumbnailGenerationTask(FileDataStorageManager storageManager, Account account){
-            if (storageManager == null)
+            if (storageManager == null) {
                 throw new IllegalArgumentException("storageManager must not be NULL");
+            }
             mStorageManager = storageManager;
             mAccount = account;
             mImageViewReference = null;
@@ -209,6 +213,7 @@ public class ThumbnailsCacheManager {
             mImageViewReference = new WeakReference<ImageView>(imageView);
         }
 
+        @SuppressFBWarnings("Dm")
         @Override
         protected Bitmap doInBackground(Object... params) {
             Bitmap thumbnail = null;
@@ -224,17 +229,17 @@ public class ThumbnailsCacheManager {
                 }
 
                 mFile = params[0];
-                if (params.length == 2){
+                if (params.length == 2) {
                     mImageKey = (String) params[1];
                 }
-                
+
                 if (mFile instanceof OCFile) {
                     thumbnail = doOCFileInBackground();
 
                     if (MimeTypeUtil.isVideo((OCFile) mFile) && thumbnail != null) {
                         thumbnail = addVideoOverlay(thumbnail);
                     }
-                }  else if (mFile instanceof File) {
+                } else if (mFile instanceof File) {
                     thumbnail = doFileInBackground();
 
                     String url = ((File) mFile).getAbsolutePath();
@@ -243,16 +248,15 @@ public class ThumbnailsCacheManager {
                     if (MimeTypeUtil.isVideo(mMimeType) && thumbnail != null) {
                         thumbnail = addVideoOverlay(thumbnail);
                     }
-                //} else {  do nothing
+                    //} else {  do nothing
                 }
 
-                }catch(Throwable t){
-                    // the app should never break due to a problem with thumbnails
-                    Log_OC.e(TAG, "Generation of thumbnail for " + mFile + " failed", t);
-                    if (t instanceof OutOfMemoryError) {
-                        System.gc();
-                    }
-                }
+            } catch(OutOfMemoryError oome) {
+                System.gc();
+            } catch (Throwable t) {
+                // the app should never break due to a problem with thumbnails
+                Log_OC.e(TAG, "Generation of thumbnail for " + mFile + " failed", t);
+            }
 
             return thumbnail;
         }
@@ -348,7 +352,7 @@ public class ThumbnailsCacheManager {
                                     mClient.exhaustResponse(get.getResponseBodyAsStream());
                                 }
                             } catch (Exception e) {
-                                e.printStackTrace();
+                                Log_OC.d(TAG, e.getMessage(), e);
                             } finally {
                                 if (get != null) {
                                     get.releaseConnection();
@@ -497,11 +501,13 @@ public class ThumbnailsCacheManager {
                                     FileDataStorageManager storageManager, Account account) {
             mAvatarGenerationListener = new WeakReference<>(avatarGenerationListener);
             mCallContext = callContext;
-            if (storageManager == null)
+            if (storageManager == null) {
                 throw new IllegalArgumentException("storageManager must not be NULL");
+            }
             mAccount = account;
         }
 
+        @SuppressFBWarnings("Dm")
         @Override
         protected Bitmap doInBackground(String... params) {
             Bitmap thumbnail = null;
@@ -517,12 +523,11 @@ public class ThumbnailsCacheManager {
                 mUsername = params[0];
                 thumbnail = doAvatarInBackground();
 
+            } catch(OutOfMemoryError oome) {
+                System.gc(); // todo, does this really make sense?
             } catch(Throwable t){
                 // the app should never break due to a problem with avatars
                 Log_OC.e(TAG, "Generation of avatar for " + mUsername + " failed", t);
-                if (t instanceof OutOfMemoryError) {
-                    System.gc();
-                }
             }
 
             return thumbnail;
@@ -530,15 +535,12 @@ public class ThumbnailsCacheManager {
 
         protected void onPostExecute(Bitmap bitmap) {
             if (bitmap != null) {
-                if (mAvatarGenerationListener != null) {
-                    AvatarGenerationListener listener = mAvatarGenerationListener.get();
-                    AvatarGenerationTask avatarWorkerTask = getAvatarWorkerTask(mCallContext);
-                    if (this == avatarWorkerTask) {
-                        if (listener.shouldCallGeneratedCallback(mUsername, mCallContext)) {
-                            listener.avatarGenerated(new BitmapDrawable(bitmap), mCallContext);
-                        }
+                AvatarGenerationListener listener = mAvatarGenerationListener.get();
+                AvatarGenerationTask avatarWorkerTask = getAvatarWorkerTask(mCallContext);
+                if (this == avatarWorkerTask
+                        && listener.shouldCallGeneratedCallback(mUsername, mCallContext)) {
+                        listener.avatarGenerated(new BitmapDrawable(bitmap), mCallContext);
                     }
-                }
             }
         }
 
@@ -632,7 +634,7 @@ public class ThumbnailsCacheManager {
         if (bitmapWorkerTask != null) {
             final Object bitmapData = bitmapWorkerTask.mFile;
             // If bitmapData is not yet set or it differs from the new data
-            if (bitmapData == null || bitmapData != file) {
+            if (bitmapData == null || !bitmapData.equals(file)) {
                 // Cancel previous task
                 bitmapWorkerTask.cancel(true);
                 Log_OC.v(TAG, "Cancelled generation of thumbnail for a reused imageView");
@@ -646,10 +648,11 @@ public class ThumbnailsCacheManager {
     }
 
     public static boolean cancelPotentialAvatarWork(Object file, Object callContext) {
-        if (callContext instanceof ImageView)
-            return cancelPotentialAvatarWork(file, (ImageView)callContext);
-        else if (callContext instanceof MenuItem)
+        if (callContext instanceof ImageView) {
+            return cancelPotentialAvatarWork(file, (ImageView) callContext);
+        } else if (callContext instanceof MenuItem) {
             return cancelPotentialAvatarWork(file, (MenuItem)callContext);
+        }
 
         return false;
     }
@@ -660,7 +663,7 @@ public class ThumbnailsCacheManager {
         if (avatarWorkerTask != null) {
             final Object usernameData = avatarWorkerTask.mUsername;
             // If usernameData is not yet set or it differs from the new data
-            if (usernameData == null || usernameData != file) {
+            if (usernameData == null || !usernameData.equals(file)) {
                 // Cancel previous task
                 avatarWorkerTask.cancel(true);
                 Log_OC.v(TAG, "Cancelled generation of avatar for a reused imageView");
@@ -679,7 +682,7 @@ public class ThumbnailsCacheManager {
         if (avatarWorkerTask != null) {
             final Object usernameData = avatarWorkerTask.mUsername;
             // If usernameData is not yet set or it differs from the new data
-            if (usernameData == null || usernameData != file) {
+            if (usernameData == null || !usernameData.equals(file)) {
                 // Cancel previous task
                 avatarWorkerTask.cancel(true);
                 Log_OC.v(TAG, "Cancelled generation of avatar for a reused imageView");
@@ -734,7 +737,6 @@ public class ThumbnailsCacheManager {
 
         // offset to top left
         double ox = - xm;
-        double oy = thumbnail.getHeight() - ym;
 
 
         c.drawBitmap(thumbnail, 0, 0, null);
@@ -749,10 +751,11 @@ public class ThumbnailsCacheManager {
     }
 
     public static AvatarGenerationTask getAvatarWorkerTask(Object callContext) {
-        if (callContext instanceof ImageView)
+        if (callContext instanceof ImageView) {
             return getAvatarWorkerTask(((ImageView)callContext).getDrawable());
-        else if (callContext instanceof MenuItem)
+        } else if (callContext instanceof MenuItem) {
             return getAvatarWorkerTask(((MenuItem)callContext).getIcon());
+        }
 
         return null;
     }

+ 6 - 5
src/com/owncloud/android/datamodel/UploadsStorageManager.java

@@ -43,6 +43,7 @@ import java.util.Observable;
 public class UploadsStorageManager extends Observable {
 
     private ContentResolver mContentResolver;
+    private static final String AND = " AND ";
 
     static private final String TAG = UploadsStorageManager.class.getSimpleName();
 
@@ -391,8 +392,8 @@ public class UploadsStorageManager extends Observable {
      */
     public OCUpload[] getFailedButNotDelayedUploads() {
         return getUploads(
-            ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + " AND " +
-                ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + " AND " +
+            ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + AND +
+                ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
                 ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
             null
         );
@@ -405,8 +406,8 @@ public class UploadsStorageManager extends Observable {
     public long clearFailedButNotDelayedUploads() {
         long result = getDB().delete(
             ProviderTableMeta.CONTENT_URI_UPLOADS,
-            ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + " AND " +
-                ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + " AND " +
+            ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + AND +
+                ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
                 ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
             null
         );
@@ -436,7 +437,7 @@ public class UploadsStorageManager extends Observable {
         long result = getDB().delete(
                 ProviderTableMeta.CONTENT_URI_UPLOADS,
                 ProviderTableMeta.UPLOADS_STATUS + "=? OR " + ProviderTableMeta.UPLOADS_STATUS + "=? AND " +
-                ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + " AND " +
+                ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
                 ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
                 whereArgs
         );

+ 8 - 4
src/com/owncloud/android/datastorage/DataStorageProvider.java

@@ -60,8 +60,9 @@ public class DataStorageProvider {
     private DataStorageProvider() {}
 
     public StoragePoint[] getAvailableStoragePoints() {
-        if (mCachedStoragePoints.size() != 0)
+        if (mCachedStoragePoints.size() != 0) {
             return mCachedStoragePoints.toArray(new StoragePoint[mCachedStoragePoints.size()]);
+        }
 
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             for (File f : MainApp.getAppContext().getExternalFilesDirs(null)) {
@@ -70,19 +71,22 @@ public class DataStorageProvider {
                 }
             }
         } else {
-            for (IStoragePointProvider p : mStorageProviders)
+            for (IStoragePointProvider p : mStorageProviders) {
                 if (p.canProvideStoragePoints()) {
                     mCachedStoragePoints.addAll(p.getAvailableStoragePoint());
                 }
+            }
         }
 
         return mCachedStoragePoints.toArray(new StoragePoint[mCachedStoragePoints.size()]);
     }
 
     public String getStorageDescriptionByPath(String path) {
-        for (StoragePoint s : getAvailableStoragePoints())
-            if (s.getPath().equals(path))
+        for (StoragePoint s : getAvailableStoragePoints()) {
+            if (s.getPath().equals(path)) {
                 return s.getDescription();
+            }
+        }
         return MainApp.getAppContext().getString(R.string.storage_description_unknown);
     }
 

+ 4 - 2
src/com/owncloud/android/datastorage/UniqueStorageList.java

@@ -36,8 +36,9 @@ public class UniqueStorageList extends Vector<StoragePoint> {
             for (StoragePoint s : this) {
                 String thisCanonPath = new File(s.getPath()).getCanonicalPath();
                 String otherCanonPath = new File(sp.getPath()).getCanonicalPath();
-                if (thisCanonPath.equals(otherCanonPath))
+                if (thisCanonPath.equals(otherCanonPath)) {
                     return true;
+                }
             }
         } catch (IOException e) {
             return false;
@@ -47,8 +48,9 @@ public class UniqueStorageList extends Vector<StoragePoint> {
 
     @Override
     public synchronized boolean addAll(Collection<? extends StoragePoint> collection) {
-        for (StoragePoint sp : collection)
+        for (StoragePoint sp : collection) {
             add(sp);
+        }
         return true;
     }
 }

+ 16 - 12
src/com/owncloud/android/datastorage/providers/AbstractCommandLineStoragePoint.java

@@ -21,15 +21,18 @@
 
 package com.owncloud.android.datastorage.providers;
 
+import com.owncloud.android.lib.common.utils.Log_OC;
+
 import java.io.InputStream;
 import java.util.Arrays;
 
 /**
  * @author Bartosz Przybylski
  */
-abstract public class AbstractCommandLineStoragePoint extends AbstractStoragePointProvider {
+abstract class AbstractCommandLineStoragePoint extends AbstractStoragePointProvider {
+    private static final String TAG = AbstractCommandLineStoragePoint.class.getSimpleName();
 
-    static protected final int sCommandLineOKReturnValue = 0;
+    private static final int COMMAND_LINE_OK_RETURN_VALUE = 0;
 
     protected abstract String[] getCommand();
 
@@ -42,23 +45,24 @@ abstract public class AbstractCommandLineStoragePoint extends AbstractStoragePoi
         } catch (Exception e) {
             return false;
         }
-        return process != null && process.exitValue() == sCommandLineOKReturnValue;
+        return process != null && process.exitValue() == COMMAND_LINE_OK_RETURN_VALUE;
     }
 
-    protected String getCommandLineResult() {
-        String s = "";
+    String getCommandLineResult() {
+        StringBuilder s = new StringBuilder();
         try {
-            final Process process = new ProcessBuilder().command(getCommand())
-                    .redirectErrorStream(true).start();
+            final Process process = new ProcessBuilder().command(getCommand()).redirectErrorStream(true).start();
 
             process.waitFor();
             final InputStream is = process.getInputStream();
             final byte buffer[] = new byte[1024];
-            while (is.read(buffer) != -1)
-                s += new String(buffer);
+            while (is.read(buffer) != -1) {
+                s.append(new String(buffer, "UTF8"));
+            }
             is.close();
-        } catch (final Exception e) { }
-        return s;
+        } catch (final Exception e) {
+            Log_OC.e(TAG, "Error retrieving command line results!", e);
+        }
+        return s.toString();
     }
-
 }

+ 11 - 5
src/com/owncloud/android/datastorage/providers/AbstractStoragePointProvider.java

@@ -29,13 +29,19 @@ import java.util.Vector;
 /**
  * @author Bartosz Przybylski
  */
-abstract public class AbstractStoragePointProvider implements IStoragePointProvider {
+abstract class AbstractStoragePointProvider implements IStoragePointProvider {
 
-    protected boolean canBeAddedToAvailableList(Vector<StoragePoint> currentList, String path) {
-        if (path == null) return false;
-        for (StoragePoint storage : currentList)
-            if (storage.getPath().equals(path))
+    boolean canBeAddedToAvailableList(Vector<StoragePoint> currentList, String path) {
+        if (path == null) {
+            return false;
+        }
+
+        for (StoragePoint storage : currentList) {
+            if (storage.getPath().equals(path)) {
                 return false;
+            }
+        }
+
         File f = new File(path);
         return f.exists() && f.isDirectory() && f.canRead() && f.canWrite();
     }

+ 6 - 3
src/com/owncloud/android/datastorage/providers/EnvironmentStoragePointProvider.java

@@ -50,9 +50,12 @@ public class EnvironmentStoragePointProvider extends AbstractStoragePointProvide
 
     private void addEntriesFromEnv(Vector<StoragePoint> result, String envName) {
         String env = System.getenv(envName);
-        if (env != null)
-            for (String p : env.split(":"))
-                if (canBeAddedToAvailableList(result, p))
+        if (env != null) {
+            for (String p : env.split(":")) {
+                if (canBeAddedToAvailableList(result, p)) {
                     result.add(new StoragePoint(p, p));
+                }
+            }
+        }
     }
 }

+ 5 - 3
src/com/owncloud/android/datastorage/providers/HardcodedStoragePointProvider.java

@@ -30,7 +30,7 @@ import java.util.Vector;
  */
 public class HardcodedStoragePointProvider extends AbstractStoragePointProvider {
 
-    static private final String[] sPaths = {
+    private static final String[] PATHS = {
             "/mnt/external_sd/",
             "/mnt/extSdCard/",
             "/storage/extSdCard",
@@ -47,9 +47,11 @@ public class HardcodedStoragePointProvider extends AbstractStoragePointProvider
     public Vector<StoragePoint> getAvailableStoragePoint() {
         Vector<StoragePoint> result = new Vector<>();
 
-        for (String s : sPaths)
-            if (canBeAddedToAvailableList(result, s))
+        for (String s : PATHS) {
+            if (canBeAddedToAvailableList(result, s)) {
                 result.add(new StoragePoint(s, s));
+            }
+        }
 
         return result;
     }

+ 8 - 5
src/com/owncloud/android/datastorage/providers/MountCommandStoragePointProvider.java

@@ -45,9 +45,11 @@ public class MountCommandStoragePointProvider extends AbstractCommandLineStorage
     public Vector<StoragePoint> getAvailableStoragePoint() {
         Vector<StoragePoint> result = new Vector<>();
 
-        for (String p : getPotentialPaths(getCommandLineResult()))
-            if (canBeAddedToAvailableList(result, p))
+        for (String p : getPotentialPaths(getCommandLineResult())) {
+            if (canBeAddedToAvailableList(result, p)) {
                 result.add(new StoragePoint(p, p));
+            }
+        }
 
         return result;
     }
@@ -55,15 +57,16 @@ public class MountCommandStoragePointProvider extends AbstractCommandLineStorage
     private Vector<String> getPotentialPaths(String mounted) {
         final Vector<String> result = new Vector<>();
 
-        for (String line : mounted.split("\n"))
+        for (String line : mounted.split("\n")) {
             if (!line.toLowerCase(Locale.US).contains("asec") && sPattern.matcher(line).matches()) {
                 String parts[] = line.split(" ");
                 for (String path : parts) {
-                    if (path.startsWith("/") &&
-                            !path.toLowerCase(Locale.US).contains("vold"))
+                    if (path.startsWith("/") && !path.toLowerCase(Locale.US).contains("vold")) {
                         result.add(path);
+                    }
                 }
             }
+        }
         return result;
     }
 }

+ 4 - 2
src/com/owncloud/android/datastorage/providers/VDCStoragePointProvider.java

@@ -58,13 +58,15 @@ public class VDCStoragePointProvider extends AbstractCommandLineStoragePoint {
             String vdcLine[] = line.split(" ");
             try {
                 int status = Integer.parseInt(vdcLine[0]);
-                if (status != sVDCVolumeList)
+                if (status != sVDCVolumeList) {
                     continue;
+                }
                 final String description = vdcLine[1];
                 final String path = vdcLine[2];
 
-                if (canBeAddedToAvailableList(result, path))
+                if (canBeAddedToAvailableList(result, path)) {
                     result.add(new StoragePoint(description, path));
+                }
 
             } catch (NumberFormatException e) {
                 Log_OC.e(TAG, "Incorrect VDC output format " + e);

+ 10 - 7
src/com/owncloud/android/db/ProviderMeta.java

@@ -44,19 +44,22 @@ public class ProviderMeta {
         public static final String CAPABILITIES_TABLE_NAME = "capabilities";
         public static final String UPLOADS_TABLE_NAME = "list_of_uploads";
         public static final String SYNCED_FOLDERS_TABLE_NAME = "synced_folders";
-        public static final Uri CONTENT_URI = Uri.parse("content://"
+
+        private static final String CONTENT_PREFIX = "content://";
+
+        public static final Uri CONTENT_URI = Uri.parse(CONTENT_PREFIX
                 + MainApp.getAuthority() + "/");
-        public static final Uri CONTENT_URI_FILE = Uri.parse("content://"
+        public static final Uri CONTENT_URI_FILE = Uri.parse(CONTENT_PREFIX
                 + MainApp.getAuthority() + "/file");
-        public static final Uri CONTENT_URI_DIR = Uri.parse("content://"
+        public static final Uri CONTENT_URI_DIR = Uri.parse(CONTENT_PREFIX
                 + MainApp.getAuthority() + "/dir");
-        public static final Uri CONTENT_URI_SHARE = Uri.parse("content://"
+        public static final Uri CONTENT_URI_SHARE = Uri.parse(CONTENT_PREFIX
                 + MainApp.getAuthority() + "/shares");
-        public static final Uri CONTENT_URI_CAPABILITIES = Uri.parse("content://"
+        public static final Uri CONTENT_URI_CAPABILITIES = Uri.parse(CONTENT_PREFIX
                 + MainApp.getAuthority() + "/capabilities");
-        public static final Uri CONTENT_URI_UPLOADS = Uri.parse("content://"
+        public static final Uri CONTENT_URI_UPLOADS = Uri.parse(CONTENT_PREFIX
                 + MainApp.getAuthority() + "/uploads");
-        public static final Uri CONTENT_URI_SYNCED_FOLDERS = Uri.parse("content://"
+        public static final Uri CONTENT_URI_SYNCED_FOLDERS = Uri.parse(CONTENT_PREFIX
                 + MainApp.getAuthority() + "/synced_folders");
 
         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.owncloud.file";

+ 1 - 1
src/com/owncloud/android/files/BootupBroadcastReceiver.java

@@ -35,7 +35,7 @@ import android.content.Intent;
  */
 public class BootupBroadcastReceiver extends BroadcastReceiver {
 
-    private static String TAG = BootupBroadcastReceiver.class.getSimpleName();
+    private static final String TAG = BootupBroadcastReceiver.class.getSimpleName();
     
     /**
      * Receives broadcast intent reporting that the system was just boot up.

+ 4 - 4
src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java

@@ -43,17 +43,17 @@ import com.owncloud.android.utils.FileStorageUtils;
 
 public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
 
-    private static String TAG = InstantUploadBroadcastReceiver.class.getName();
+    private static final String TAG = InstantUploadBroadcastReceiver.class.getName();
     // Image action
     // Unofficial action, works for most devices but not HTC. See: https://github.com/owncloud/android/issues/6
-    private static String NEW_PHOTO_ACTION_UNOFFICIAL = "com.android.camera.NEW_PICTURE";
+    private static final String NEW_PHOTO_ACTION_UNOFFICIAL = "com.android.camera.NEW_PICTURE";
     // Officially supported action since SDK 14:
     // http://developer.android.com/reference/android/hardware/Camera.html#ACTION_NEW_PICTURE
-    private static String NEW_PHOTO_ACTION = "android.hardware.action.NEW_PICTURE";
+    private static final String NEW_PHOTO_ACTION = "android.hardware.action.NEW_PICTURE";
     // Video action
     // Officially supported action since SDK 14:
     // http://developer.android.com/reference/android/hardware/Camera.html#ACTION_NEW_VIDEO
-    private static String NEW_VIDEO_ACTION = "android.hardware.action.NEW_VIDEO";
+    private static final String NEW_VIDEO_ACTION = "android.hardware.action.NEW_VIDEO";
 
     @Override
     public void onReceive(Context context, Intent intent) {

+ 13 - 15
src/com/owncloud/android/files/services/ConnectivityActionReceiver.java

@@ -70,22 +70,20 @@ public class ConnectivityActionReceiver extends BroadcastReceiver {
             Log_OC.v(TAG, "no extras");
         }
 
-        if (intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)) {
+        if (intent.getAction().equals(Intent.ACTION_POWER_CONNECTED) &&
+                (PreferenceManager.instantPictureUploadEnabled(context) &&
+                        PreferenceManager.instantPictureUploadWhenChargingOnly(context)) ||
+                (PreferenceManager.instantVideoUploadEnabled(context) &&
+                        PreferenceManager.instantVideoUploadWhenChargingOnly(context))
+                ) {
             // for the moment, only recovery of instant uploads, similar to behaviour in release 1.9.1
-            if (
-                    (PreferenceManager.instantPictureUploadEnabled(context) &&
-                            PreferenceManager.instantPictureUploadWhenChargingOnly(context)) ||
-                            (PreferenceManager.instantVideoUploadEnabled(context) &&
-                                    PreferenceManager.instantVideoUploadWhenChargingOnly(context))
-                    ) {
-                Log_OC.d(TAG, "Requesting retry of instant uploads (& friends) due to charging");
-                FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
-                requester.retryFailedUploads(
-                        context,
-                        null,
-                        UploadResult.DELAYED_FOR_CHARGING   // for the rest of enqueued when Wifi fell
-                );
-            }
+            Log_OC.d(TAG, "Requesting retry of instant uploads (& friends) due to charging");
+            FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
+            requester.retryFailedUploads(
+                    context,
+                    null,
+                    UploadResult.DELAYED_FOR_CHARGING   // for the rest of enqueued when Wifi fell
+            );
         }
 
         /**

+ 11 - 4
src/com/owncloud/android/files/services/FileDownloader.java

@@ -297,7 +297,9 @@ public class FileDownloader extends Service
          * @param file    A file that could be in the queue of downloads.
          */
         public boolean isDownloading(Account account, OCFile file) {
-            if (account == null || file == null) return false;
+            if (account == null || file == null) {
+                return false;
+            }
             return (mPendingDownloads.contains(account.name, file.getRemotePath()));
         }
 
@@ -312,7 +314,9 @@ public class FileDownloader extends Service
         public void addDatatransferProgressListener(
                 OnDatatransferProgressListener listener, Account account, OCFile file
         ) {
-            if (account == null || file == null || listener == null) return;
+            if (account == null || file == null || listener == null) {
+                return;
+            }
             mBoundListeners.put(file.getFileId(), listener);
         }
 
@@ -327,7 +331,9 @@ public class FileDownloader extends Service
         public void removeDatatransferProgressListener(
                 OnDatatransferProgressListener listener, Account account, OCFile file
         ) {
-            if (account == null || file == null || listener == null) return;
+            if (account == null || file == null || listener == null) {
+                return;
+            }
             Long fileId = file.getFileId();
             if (mBoundListeners.get(fileId) == listener) {
                 mBoundListeners.remove(fileId);
@@ -359,8 +365,9 @@ public class FileDownloader extends Service
 
         public ServiceHandler(Looper looper, FileDownloader service) {
             super(looper);
-            if (service == null)
+            if (service == null) {
                 throw new IllegalArgumentException("Received invalid NULL in parameter 'service'");
+            }
             mService = service;
         }
 

+ 16 - 6
src/com/owncloud/android/files/services/FileUploader.java

@@ -721,8 +721,9 @@ public class FileUploader extends Service
          * @param file    A file that could be in the queue of pending uploads
          */
         public boolean isUploading(Account account, OCFile file) {
-            if (account == null || file == null)
+            if (account == null || file == null) {
                 return false;
+            }
             return (mPendingUploads.contains(account.name, file.getRemotePath()));
         }
 
@@ -750,7 +751,9 @@ public class FileUploader extends Service
                 Account account,
                 OCFile file
         ) {
-            if (account == null || file == null || listener == null) return;
+            if (account == null || file == null || listener == null) {
+                return;
+            }
             String targetKey = buildRemoteName(account.name, file.getRemotePath());
             mBoundListeners.put(targetKey, listener);
         }
@@ -766,7 +769,9 @@ public class FileUploader extends Service
                 OnDatatransferProgressListener listener,
                 OCUpload ocUpload
         ) {
-            if (ocUpload == null || listener == null) return;
+            if (ocUpload == null || listener == null) {
+                return;
+            }
             String targetKey = buildRemoteName(ocUpload.getAccountName(), ocUpload.getRemotePath());
             mBoundListeners.put(targetKey, listener);
         }
@@ -784,7 +789,9 @@ public class FileUploader extends Service
                 Account account,
                 OCFile file
         ) {
-            if (account == null || file == null || listener == null) return;
+            if (account == null || file == null || listener == null) {
+                return;
+            }
             String targetKey = buildRemoteName(account.name, file.getRemotePath());
             if (mBoundListeners.get(targetKey) == listener) {
                 mBoundListeners.remove(targetKey);
@@ -802,7 +809,9 @@ public class FileUploader extends Service
                 OnDatatransferProgressListener listener,
                 OCUpload ocUpload
         ) {
-            if (ocUpload == null || listener == null) return;
+            if (ocUpload == null || listener == null) {
+                return;
+            }
             String targetKey = buildRemoteName(ocUpload.getAccountName(), ocUpload.getRemotePath());
             if (mBoundListeners.get(targetKey) == listener) {
                 mBoundListeners.remove(targetKey);
@@ -851,8 +860,9 @@ public class FileUploader extends Service
 
         public ServiceHandler(Looper looper, FileUploader service) {
             super(looper);
-            if (service == null)
+            if (service == null) {
                 throw new IllegalArgumentException("Received invalid NULL in parameter 'service'");
+            }
             mService = service;
         }
 

+ 1 - 1
src/com/owncloud/android/files/services/IndexedForest.java

@@ -43,6 +43,7 @@ public class IndexedForest<V> {
 
     private ConcurrentMap<String, Node<V>> mMap = new ConcurrentHashMap<String, Node<V>>();
 
+    @SuppressWarnings("PMD.ShortClassName")
     private class Node<V> {
         String mKey = null;
         Node<V> mParent = null;
@@ -168,7 +169,6 @@ public class IndexedForest<V> {
             /// remove ancestors if only here due to firstRemoved
             Node<V> removed = firstRemoved;
             Node<V> parent = removed.getParent();
-            boolean unlinked = false;
             while (parent != null) {
                 parent.removeChild(removed);
                 if (!parent.hasChildren()) {

+ 0 - 28
src/com/owncloud/android/files/services/OnUploadCompletedListener.java

@@ -1,28 +0,0 @@
-/**
- *   ownCloud Android client application
- *
- *   Copyright (C) 2012 Bartek Przybylski
- *   Copyright (C) 2015 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package com.owncloud.android.files.services;
-
-public interface OnUploadCompletedListener extends Runnable {
-
-    public boolean getUploadResult();
-
-    public void setUploadResult(boolean result);
-}

+ 23 - 23
src/com/owncloud/android/media/MediaControlView.java

@@ -65,8 +65,6 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
     private TextView            mEndTime, mCurrentTime;
     private boolean             mDragging;
     private static final int    SHOW_PROGRESS = 1;
-    StringBuilder               mFormatBuilder;
-    Formatter                   mFormatter;
     private ImageButton         mPauseButton;
     private ImageButton         mFfwdButton;
     private ImageButton         mRewButton;
@@ -231,9 +229,6 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
 
         mEndTime = (TextView) v.findViewById(R.id.totalTimeText);
         mCurrentTime = (TextView) v.findViewById(R.id.currentTimeText);
-        mFormatBuilder = new StringBuilder();
-        mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
-
     }
 
     
@@ -265,14 +260,12 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
         @Override
         public void handleMessage(Message msg) {
             int pos;
-            switch (msg.what) {
-                case SHOW_PROGRESS:
-                    pos = setProgress();
-                    if (!mDragging) {
-                        msg = obtainMessage(SHOW_PROGRESS);
-                        sendMessageDelayed(msg, 1000 - (pos % 1000));
-                    }
-                    break;
+            if (msg.what == SHOW_PROGRESS) {
+                pos = setProgress();
+                if (!mDragging) {
+                    msg = obtainMessage(SHOW_PROGRESS);
+                    sendMessageDelayed(msg, 1000 - (pos % 1000));
+                }
             }
         }
     };
@@ -284,7 +277,8 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
         int minutes = (totalSeconds / 60) % 60;
         int hours   = totalSeconds / 3600;
 
-        mFormatBuilder.setLength(0);
+        final StringBuilder mFormatBuilder = new StringBuilder();
+        final Formatter mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
         if (hours > 0) {
             return mFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString();
         } else {
@@ -308,11 +302,12 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
             mProgress.setSecondaryProgress(percent * 10);
         }
 
-        if (mEndTime != null)
+        if (mEndTime != null) {
             mEndTime.setText(stringForTime(duration));
-        if (mCurrentTime != null)
+        }
+        if (mCurrentTime != null) {
             mCurrentTime.setText(stringForTime(position));
-
+        }
         return position;
     }
     
@@ -355,8 +350,9 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
     }
 
     public void updatePausePlay() {
-        if (mRoot == null || mPauseButton == null)
+        if (mRoot == null || mPauseButton == null) {
             return;
+        }
 
         if (mPlayer.isPlaying()) {
             mPauseButton.setImageResource(android.R.drawable.ic_media_pause);
@@ -406,7 +402,9 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
             pos = mPlayer.getCurrentPosition();
             pos -= 5000;
             mPlayer.seekTo(pos);
-            if (!playing) mPlayer.pause();  // necessary in some 2.3.x devices 
+            if (!playing) {
+                mPlayer.pause();  // necessary in some 2.3.x devices
+            }
             setProgress();
             break;
 
@@ -414,10 +412,11 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
             pos = mPlayer.getCurrentPosition();
             pos += 15000;
             mPlayer.seekTo(pos);
-            if (!playing) mPlayer.pause(); // necessary in some 2.3.x devices
+            if (!playing) {
+                mPlayer.pause(); // necessary in some 2.3.x devices
+            }
             setProgress();
             break;
-        
         }
     }
     
@@ -433,8 +432,9 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
         long duration = mPlayer.getDuration();
         long newposition = (duration * progress) / 1000L;
         mPlayer.seekTo( (int) newposition);
-        if (mCurrentTime != null)
-            mCurrentTime.setText(stringForTime( (int) newposition));
+        if (mCurrentTime != null) {
+            mCurrentTime.setText(stringForTime((int) newposition));
+        }
     }
     
     /**

+ 6 - 4
src/com/owncloud/android/media/MediaService.java

@@ -65,10 +65,10 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
     public static final String ACTION_PLAY_FILE = MY_PACKAGE + ".action.PLAY_FILE";
     public static final String ACTION_STOP_ALL = MY_PACKAGE + ".action.STOP_ALL";
 
-    /// Keys to add extras to the action
+    /// PreferenceKeys to add extras to the action
     public static final String EXTRA_FILE = MY_PACKAGE + ".extra.FILE";
     public static final String EXTRA_ACCOUNT = MY_PACKAGE + ".extra.ACCOUNT";
-    public static String EXTRA_START_POSITION = MY_PACKAGE + ".extra.START_POSITION";
+    public static final String EXTRA_START_POSITION = MY_PACKAGE + ".extra.START_POSITION";
     public static final String EXTRA_PLAY_ON_LOAD = MY_PACKAGE + ".extra.PLAY_ON_LOAD";
 
 
@@ -621,16 +621,18 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
             // focus gain; check AudioManager.AUDIOFOCUS_* values
             mAudioFocus = AudioFocus.FOCUS;
             // restart media player with new focus settings
-            if (mState == State.PLAYING)
+            if (mState == State.PLAYING) {
                 configAndStartMediaPlayer();
+            }
             
         } else if (focusChange < 0) {
             // focus loss; check AudioManager.AUDIOFOCUS_* values
             boolean canDuck = AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK == focusChange;
                 mAudioFocus = canDuck ? AudioFocus.NO_FOCUS_CAN_DUCK : AudioFocus.NO_FOCUS;
                 // start/restart/pause media player with new focus settings
-                if (mPlayer != null && mPlayer.isPlaying())
+                if (mPlayer != null && mPlayer.isPlaying()) {
                     configAndStartMediaPlayer();
+                }
         }
         
     }

+ 3 - 5
src/com/owncloud/android/operations/CreateShareWithShareeOperation.java

@@ -85,11 +85,9 @@ public class CreateShareWithShareeOperation extends SyncOperation {
         RemoteOperationResult result = operation.execute(client);
 
         
-        if (result.isSuccess()) {
-            if (result.getData().size() > 0) {
-                OCShare share = (OCShare) result.getData().get(0);
-                updateData(share);
-            } 
+        if (result.isSuccess() && result.getData().size() > 0) {
+            OCShare share = (OCShare) result.getData().get(0);
+            updateData(share);
         }
         
         return result;

+ 6 - 4
src/com/owncloud/android/operations/DownloadFileOperation.java

@@ -58,16 +58,17 @@ public class DownloadFileOperation extends RemoteOperation {
 
     
     public DownloadFileOperation(Account account, OCFile file) {
-        if (account == null)
+        if (account == null) {
             throw new IllegalArgumentException("Illegal null account in DownloadFileOperation " +
                     "creation");
-        if (file == null)
+        }
+        if (file == null) {
             throw new IllegalArgumentException("Illegal null file in DownloadFileOperation " +
                     "creation");
+        }
         
         mAccount = account;
         mFile = file;
-        
     }
 
 
@@ -162,9 +163,10 @@ public class DownloadFileOperation extends RemoteOperation {
             newFile = new File(getSavePath());
             newFile.getParentFile().mkdirs();
             moved = tmpFile.renameTo(newFile);
-            if (!moved)
+            if (!moved) {
                 result = new RemoteOperationResult(
                         RemoteOperationResult.ResultCode.LOCAL_STORAGE_NOT_MOVED);
+            }
         }
         Log_OC.i(TAG, "Download of " + mFile.getRemotePath() + " to " + getSavePath() + ": " +
                 result.getLogMessage());

+ 5 - 6
src/com/owncloud/android/operations/GetCapabilitiesOperarion.java

@@ -35,14 +35,13 @@ public class GetCapabilitiesOperarion extends SyncOperation {
         GetRemoteCapabilitiesOperation getCapabilities = new GetRemoteCapabilitiesOperation();
         RemoteOperationResult result = getCapabilities.execute(client);
 
-        if (result.isSuccess()){
+        if (result.isSuccess()
+                && result.getData() != null && result.getData().size() > 0) {
             // Read data from the result
-            if( result.getData()!= null && result.getData().size() > 0) {
-                OCCapability capability = (OCCapability) result.getData().get(0);
+            OCCapability capability = (OCCapability) result.getData().get(0);
 
-                // Save the capabilities into database
-                getStorageManager().saveCapabilities(capability);
-            }
+            // Save the capabilities into database
+            getStorageManager().saveCapabilities(capability);
         }
 
         return result;

+ 11 - 14
src/com/owncloud/android/operations/OAuth2GetAccessToken.java

@@ -65,6 +65,7 @@ public class OAuth2GetAccessToken extends RemoteOperation {
     */
     
     @Override
+    @SuppressWarnings("PMD.AvoidDuplicateLiterals")
     protected RemoteOperationResult run(OwnCloudClient client) {
         RemoteOperationResult result = null;
         PostMethod postMethod = null;
@@ -115,20 +116,20 @@ public class OAuth2GetAccessToken extends RemoteOperation {
             result = new RemoteOperationResult(e);
             
         } finally {
-            if (postMethod != null)
+            if (postMethod != null) {
                 postMethod.releaseConnection();    // let the connection available for other methods
-            
-            if (result.isSuccess()) {
-                Log_OC.i(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + result.getLogMessage());
-            
+            }
+
+            final String code = "code";
+            final String oauth_token_request = "OAuth2 TOKEN REQUEST with auth code ";
+            if (result !=  null && result.isSuccess()) {
+                Log_OC.i(TAG, oauth_token_request + mOAuth2ParsedAuthorizationResponse.get(code) + " to " + client.getWebdavUri() + ": " + result.getLogMessage());
             } else if (result.getException() != null) {
-                Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + result.getLogMessage(), result.getException());
-                
+                Log_OC.e(TAG, oauth_token_request + mOAuth2ParsedAuthorizationResponse.get(code) + " to " + client.getWebdavUri() + ": " + result.getLogMessage(), result.getException());
             } else if (result.getCode() == ResultCode.OAUTH2_ERROR) {
-                Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + ((mResultTokenMap != null) ? mResultTokenMap.get(OAuth2Constants.KEY_ERROR) : "NULL"));
-                    
+                Log_OC.e(TAG, oauth_token_request + mOAuth2ParsedAuthorizationResponse.get(code) + " to " + client.getWebdavUri() + ": " + ((mResultTokenMap != null) ? mResultTokenMap.get(OAuth2Constants.KEY_ERROR) : "NULL"));
             } else {
-                Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + result.getLogMessage());
+                Log_OC.e(TAG, oauth_token_request + mOAuth2ParsedAuthorizationResponse.get(code) + " to " + client.getWebdavUri() + ": " + result.getLogMessage());
             }
         }
         
@@ -141,7 +142,6 @@ public class OAuth2GetAccessToken extends RemoteOperation {
         int i = 0;
         String key = "";
         String value = "";
-        StringBuilder sb = new StringBuilder();
         while (pairs.length > i) {
             int j = 0;
             String[] part = pairs[i].split("=");
@@ -149,13 +149,10 @@ public class OAuth2GetAccessToken extends RemoteOperation {
                 String p = part[j];
                 if (j == 0) {
                     key = p;
-                    sb.append(key + " = ");
                 } else if (j == 1) {
                     value = p;
                     mOAuth2ParsedAuthorizationResponse.put(key, value);
-                    sb.append(value + "\n");
                 }
-
                 Log_OC.v(TAG, "[" + i + "," + j + "] = " + p);
                 j++;
             }

+ 3 - 1
src/com/owncloud/android/operations/RefreshFolderOperation.java

@@ -58,6 +58,7 @@ import java.util.Vector;
  *  
  *  Does NOT enter in the child folders to synchronize their contents also.
  */
+@SuppressWarnings("PMD.AvoidDuplicateLiterals")
 public class RefreshFolderOperation extends RemoteOperation {
 
     private static final String TAG = RefreshFolderOperation.class.getSimpleName();
@@ -319,8 +320,9 @@ public class RefreshFolderOperation extends RemoteOperation {
                     // should be a different result code, but will do the job
             }
         } else {
-            if (result.getCode() == ResultCode.FILE_NOT_FOUND)
+            if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
                 removeLocalFolder();
+            }
         }
         
         return result;

+ 4 - 2
src/com/owncloud/android/operations/RenameFileOperation.java

@@ -25,6 +25,7 @@ import java.io.File;
 import java.io.IOException;
 
 import com.owncloud.android.MainApp;
+import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.lib.common.OwnCloudClient;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@@ -128,8 +129,9 @@ public class RenameFileOperation extends SyncOperation {
             String oldPath = mFile.getStoragePath();
             File f = new File(oldPath);
             String parentStoragePath = f.getParent();
-            if (!parentStoragePath.endsWith(File.separator))
+            if (!parentStoragePath.endsWith(File.separator)) {
                 parentStoragePath += File.separator;
+            }
             if (f.renameTo(new File(parentStoragePath + mNewName))) {
                 String newPath = parentStoragePath + mNewName;
                 mFile.setStoragePath(newPath);
@@ -137,7 +139,7 @@ public class RenameFileOperation extends SyncOperation {
                 // notify MediaScanner about removed file
                 getStorageManager().deleteFileInMediaScan(oldPath);
                 // notify to scan about new file
-                getStorageManager().triggerMediaScan(newPath);
+                FileDataStorageManager.triggerMediaScan(newPath);
             }
             // else - NOTHING: the link to the local file is kept although the local name
             // can't be updated

+ 4 - 4
src/com/owncloud/android/operations/SynchronizeFileOperation.java

@@ -40,10 +40,9 @@ import com.owncloud.android.utils.FileStorageUtils;
 /**
  * Remote operation performing the read of remote file in the ownCloud server.
  */
-
 public class SynchronizeFileOperation extends SyncOperation {
 
-    private String TAG = SynchronizeFileOperation.class.getSimpleName();
+    private static final String TAG = SynchronizeFileOperation.class.getSimpleName();
 
     private OCFile mLocalFile;
     private String mRemotePath;
@@ -70,7 +69,7 @@ public class SynchronizeFileOperation extends SyncOperation {
      * <p/>
      * Useful for direct synchronization of a single file.
      *
-     * @param
+     * @param remotePath       remote path of the file
      * @param account          ownCloud account holding the file.
      * @param syncFileContents When 'true', transference of data will be started by the
      *                         operation if needed and no conflict is detected.
@@ -205,7 +204,7 @@ public class SynchronizeFileOperation extends SyncOperation {
             if (mServerFile != null) {
 
                 /// check changes in server and local file
-                boolean serverChanged = false;
+                boolean serverChanged;
                 if (mLocalFile.getEtag() == null || mLocalFile.getEtag().length() == 0) {
                     // file uploaded (null) or downloaded ("") before upgrade to version 1.8.0; check the old condition
                     serverChanged = mServerFile.getModificationTimestamp() !=
@@ -234,6 +233,7 @@ public class SynchronizeFileOperation extends SyncOperation {
                         // So, an instance of SynchronizeFileOperation created with
                         // syncFileContents == false is completely useless when we suspect
                         // that an upload is necessary (for instance, in FileObserverService).
+                        Log_OC.d(TAG, "Nothing to do here");
                     }
                     result = new RemoteOperationResult(ResultCode.OK);
 

+ 2 - 1
src/com/owncloud/android/operations/SynchronizeFolderOperation.java

@@ -233,8 +233,9 @@ public class SynchronizeFolderOperation extends SyncOperation {
                     // should be a different result code, but will do the job
             }
         } else {
-            if (result.getCode() == ResultCode.FILE_NOT_FOUND)
+            if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
                 removeLocalFolder();
+            }
         }
         
 

+ 2 - 1
src/com/owncloud/android/operations/UpdateOCVersionOperation.java

@@ -107,8 +107,9 @@ public class UpdateOCVersionOperation extends RemoteOperation {
             Log_OC.e(TAG, "Check for update of ownCloud server version at " + client.getWebdavUri() + ": " + result.getLogMessage(), e);
             
         } finally {
-            if (get != null) 
+            if (get != null) {
                 get.releaseConnection();
+            }
         }
         return result;
     }

+ 17 - 8
src/com/owncloud/android/operations/UploadFileOperation.java

@@ -147,11 +147,13 @@ public class UploadFileOperation extends SyncOperation {
                                int localBehaviour,
                                Context context
     ) {
-        if (account == null)
+        if (account == null) {
             throw new IllegalArgumentException("Illegal NULL account in UploadFileOperation " +
                     "creation");
-        if (upload == null)
+        }
+        if (upload == null) {
             throw new IllegalArgumentException("Illegal NULL file in UploadFileOperation creation");
+        }
         if (upload.getLocalPath() == null || upload.getLocalPath().length() <= 0) {
             throw new IllegalArgumentException(
                     "Illegal file in UploadFileOperation; storage path invalid: "
@@ -286,6 +288,7 @@ public class UploadFileOperation extends SyncOperation {
     }
 
     @Override
+    @SuppressWarnings("PMD.AvoidDuplicateLiterals")
     protected RemoteOperationResult run(OwnCloudClient client) {
         mCancellationRequested.set(false);
         mUploadStarted.set(true);
@@ -308,7 +311,7 @@ public class UploadFileOperation extends SyncOperation {
 
             /// check if the file continues existing before schedule the operation
             if (!originalFile.exists()) {
-                Log_OC.d(TAG, mOriginalStoragePath.toString() + " not exists anymore");
+                Log_OC.d(TAG, mOriginalStoragePath + " not exists anymore");
                 return new RemoteOperationResult(ResultCode.LOCAL_FILE_NOT_FOUND);
             }
 
@@ -581,7 +584,7 @@ public class UploadFileOperation extends SyncOperation {
             return remotePath;
         }
 
-        int pos = remotePath.lastIndexOf(".");
+        int pos = remotePath.lastIndexOf('.');
         String suffix = "";
         String extension = "";
         if (pos >= 0) {
@@ -709,15 +712,17 @@ public class UploadFileOperation extends SyncOperation {
 
             } finally {
                 try {
-                    if (in != null)
+                    if (in != null) {
                         in.close();
+                    }
                 } catch (Exception e) {
                     Log_OC.d(TAG, "Weird exception while closing input stream for " +
                             mOriginalStoragePath + " (ignoring)", e);
                 }
                 try {
-                    if (out != null)
+                    if (out != null) {
                         out.close();
+                    }
                 } catch (Exception e) {
                     Log_OC.d(TAG, "Weird exception while closing output stream for " +
                             targetFile.getAbsolutePath() + " (ignoring)", e);
@@ -760,8 +765,12 @@ public class UploadFileOperation extends SyncOperation {
                         // the best option could be show a warning message
                     }
                     finally {
-                        if (inChannel != null) inChannel.close();
-                        if (outChannel != null) outChannel.close();
+                        if (inChannel != null) {
+                            inChannel.close();
+                        }
+                        if (outChannel != null) {
+                            outChannel.close();
+                        }
                     }
                 }
 

+ 2 - 1
src/com/owncloud/android/operations/common/SyncOperation.java

@@ -85,9 +85,10 @@ public abstract class SyncOperation extends RemoteOperation {
 	 */
 	public RemoteOperationResult execute(OwnCloudClient client,
                                          FileDataStorageManager storageManager) {
-        if (storageManager == null)
+        if (storageManager == null) {
             throw new IllegalArgumentException("Trying to execute a sync operation with a " +
                     "NULL storage manager");
+        }
         mStorageManager = storageManager;
 		return super.execute(client);
 	}

+ 153 - 144
src/com/owncloud/android/providers/FileContentProvider.java

@@ -55,10 +55,12 @@ import com.owncloud.android.utils.MimeType;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Locale;
 
 /**
  * The ContentProvider for the ownCloud App.
  */
+@SuppressWarnings("PMD.AvoidDuplicateLiterals")
 public class FileContentProvider extends ContentProvider {
 
     private DataBaseHelper mDbHelper;
@@ -73,9 +75,15 @@ public class FileContentProvider extends ContentProvider {
 
     private static final String TAG = FileContentProvider.class.getSimpleName();
 
-    private final String MAX_SUCCESSFUL_UPLOADS = "30";
-
     private UriMatcher mUriMatcher;
+    // todo avoid string concatenation and use string formatting instead later.
+    private static final String ERROR = "ERROR ";
+    private static final String SQL = "SQL";
+    private static final String INTEGER = " INTEGER, ";
+    private static final String TEXT = " TEXT, ";
+    private static final String ALTER_TABLE = "ALTER TABLE ";
+    private static final String ADD_COLUMN = " ADD COLUMN ";
+    private static final String UPGRADE_VERSION_MSG = "OUT of the ADD in onUpgrade; oldVersion == %d, newVersion == %d";
 
     @Override
     public int delete(Uri uri, String where, String[] whereArgs) {
@@ -249,7 +257,7 @@ public class FileContentProvider extends ContentProvider {
                     if (rowId > 0) {
                         return ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, rowId);
                     } else {
-                        throw new SQLException("ERROR " + uri);
+                        throw new SQLException(ERROR + uri);
                     }
                 } else {
                     // file is already inserted; race condition, let's avoid a duplicated entry
@@ -269,7 +277,7 @@ public class FileContentProvider extends ContentProvider {
                     insertedShareUri =
                             ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_SHARE, rowId);
                 } else {
-                    throw new SQLException("ERROR " + uri);
+                    throw new SQLException(ERROR + uri);
 
                 }
                 updateFilesTableAccordingToShareInsertion(db, values);
@@ -282,7 +290,7 @@ public class FileContentProvider extends ContentProvider {
                     insertedCapUri =
                             ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_CAPABILITIES, id);
                 } else {
-                    throw new SQLException("ERROR " + uri);
+                    throw new SQLException(ERROR + uri);
 
                 }
                 return insertedCapUri;
@@ -295,7 +303,7 @@ public class FileContentProvider extends ContentProvider {
                             ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_UPLOADS, uploadId);
                     trimSuccessfulUploads(db);
                 } else {
-                    throw new SQLException("ERROR " + uri);
+                    throw new SQLException(ERROR + uri);
 
                 }
                 return insertedUploadUri;
@@ -560,7 +568,7 @@ public class FileContentProvider extends ContentProvider {
         @Override
         public void onCreate(SQLiteDatabase db) {
             // files table
-            Log_OC.i("SQL", "Entering in onCreate");
+            Log_OC.i(SQL, "Entering in onCreate");
             createFilesTable(db);
 
             // Create ocshares table
@@ -578,21 +586,21 @@ public class FileContentProvider extends ContentProvider {
 
         @Override
         public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
-            Log_OC.i("SQL", "Entering in onUpgrade");
+            Log_OC.i(SQL, "Entering in onUpgrade");
             boolean upgraded = false;
             if (oldVersion == 1 && newVersion >= 2) {
-                Log_OC.i("SQL", "Entering in the #1 ADD in onUpgrade");
-                db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                           " ADD COLUMN " + ProviderTableMeta.FILE_KEEP_IN_SYNC  + " INTEGER " +
+                Log_OC.i(SQL, "Entering in the #1 ADD in onUpgrade");
+                db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                        ADD_COLUMN + ProviderTableMeta.FILE_KEEP_IN_SYNC  + " INTEGER " +
                            " DEFAULT 0");
                 upgraded = true;
             }
             if (oldVersion < 3 && newVersion >= 3) {
-                Log_OC.i("SQL", "Entering in the #2 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #2 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
-                    db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                               " ADD COLUMN " + ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA  +
+                    db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA  +
                                " INTEGER " + " DEFAULT 0");
 
                     // assume there are not local changes pending to upload
@@ -608,11 +616,11 @@ public class FileContentProvider extends ContentProvider {
                 }
             }
             if (oldVersion < 4 && newVersion >= 4) {
-                Log_OC.i("SQL", "Entering in the #3 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #3 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
-                    db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                            " ADD COLUMN " + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA +
+                    db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA +
                             " INTEGER " + " DEFAULT 0");
 
                     db.execSQL("UPDATE " + ProviderTableMeta.FILE_TABLE_NAME +
@@ -626,16 +634,16 @@ public class FileContentProvider extends ContentProvider {
                     db.endTransaction();
                 }
             }
-            if (!upgraded)
-                Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
-                        ", newVersion == " + newVersion);
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
 
             if (oldVersion < 5 && newVersion >= 5) {
-                Log_OC.i("SQL", "Entering in the #4 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #4 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
-                    db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                            " ADD COLUMN " + ProviderTableMeta.FILE_ETAG + " TEXT " +
+                    db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_ETAG + " TEXT " +
                             " DEFAULT NULL");
 
                     upgraded = true;
@@ -644,20 +652,20 @@ public class FileContentProvider extends ContentProvider {
                     db.endTransaction();
                 }
             }
-            if (!upgraded)
-                Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
-                        ", newVersion == " + newVersion);
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
 
             if (oldVersion < 6 && newVersion >= 6) {
-                Log_OC.i("SQL", "Entering in the #5 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #5 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
-                    db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                            " ADD COLUMN " + ProviderTableMeta.FILE_SHARED_VIA_LINK + " INTEGER " +
+                    db .execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_SHARED_VIA_LINK + " INTEGER " +
                             " DEFAULT 0");
 
-                    db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                            " ADD COLUMN " + ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT " +
+                    db .execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT " +
                             " DEFAULT NULL");
 
                     // Create table ocshares
@@ -669,20 +677,20 @@ public class FileContentProvider extends ContentProvider {
                     db.endTransaction();
                 }
             }
-            if (!upgraded)
-                Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
-                        ", newVersion == " + newVersion);
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
 
             if (oldVersion < 7 && newVersion >= 7) {
-                Log_OC.i("SQL", "Entering in the #7 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #7 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
-                    db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                            " ADD COLUMN " + ProviderTableMeta.FILE_PERMISSIONS + " TEXT " +
+                    db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_PERMISSIONS + " TEXT " +
                             " DEFAULT NULL");
 
-                    db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                            " ADD COLUMN " + ProviderTableMeta.FILE_REMOTE_ID + " TEXT " +
+                    db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_REMOTE_ID + " TEXT " +
                             " DEFAULT NULL");
 
                     upgraded = true;
@@ -691,16 +699,16 @@ public class FileContentProvider extends ContentProvider {
                     db.endTransaction();
                 }
             }
-            if (!upgraded)
-                Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
-                        ", newVersion == " + newVersion);
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
 
             if (oldVersion < 8 && newVersion >= 8) {
-                Log_OC.i("SQL", "Entering in the #8 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #8 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
-                    db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                            " ADD COLUMN " + ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER " +
+                    db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER " +
                             " DEFAULT 0");
 
                     upgraded = true;
@@ -709,16 +717,16 @@ public class FileContentProvider extends ContentProvider {
                     db.endTransaction();
                 }
             }
-            if (!upgraded)
-                Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
-                        ", newVersion == " + newVersion);
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
 
             if (oldVersion < 9 && newVersion >= 9) {
-                Log_OC.i("SQL", "Entering in the #9 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #9 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
-                    db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                            " ADD COLUMN " + ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER " +
+                    db .execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER " +
                             " DEFAULT 0");
 
                     upgraded = true;
@@ -727,25 +735,25 @@ public class FileContentProvider extends ContentProvider {
                     db.endTransaction();
                 }
             }
-            if (!upgraded)
-                Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
-                        ", newVersion == " + newVersion);
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
 
             if (oldVersion < 10 && newVersion >= 10) {
-                Log_OC.i("SQL", "Entering in the #10 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #10 ADD in onUpgrade");
                 updateAccountName(db);
                 upgraded = true;
             }
-             if (!upgraded)
-                Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
-                        ", newVersion == " + newVersion);
+             if (!upgraded) {
+                 Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+             }
 
             if (oldVersion < 11 && newVersion >= 11) {
-                Log_OC.i("SQL", "Entering in the #11 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #11 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
-                    db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                            " ADD COLUMN " + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT " +
+                    db .execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT " +
                             " DEFAULT NULL");
 
                     upgraded = true;
@@ -754,16 +762,16 @@ public class FileContentProvider extends ContentProvider {
                     db.endTransaction();
                 }
             }
-            if (!upgraded)
-                Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
-                        ", newVersion == " + newVersion);
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
 
             if (oldVersion < 12 && newVersion >= 12) {
-                Log_OC.i("SQL", "Entering in the #12 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #12 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
-                    db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
-                            " ADD COLUMN " + ProviderTableMeta.FILE_SHARED_WITH_SHAREE + " INTEGER " +
+                    db .execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.FILE_SHARED_WITH_SHAREE + " INTEGER " +
                             " DEFAULT 0");
                     upgraded = true;
                     db.setTransactionSuccessful();
@@ -771,12 +779,12 @@ public class FileContentProvider extends ContentProvider {
                     db.endTransaction();
                 }
             }
-            if (!upgraded)
-                Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
-                        ", newVersion == " + newVersion);
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
 
             if (oldVersion < 13 && newVersion >= 13) {
-                Log_OC.i("SQL", "Entering in the #13 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #13 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
                     // Create capabilities table
@@ -789,7 +797,7 @@ public class FileContentProvider extends ContentProvider {
             }
 
             if (oldVersion < 14 && newVersion >= 14) {
-                Log_OC.i("SQL", "Entering in the #14 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #14 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
                     // drop old instant_upload table
@@ -804,7 +812,7 @@ public class FileContentProvider extends ContentProvider {
             }
 
             if (oldVersion < 15 && newVersion >= 15) {
-                Log_OC.i("SQL", "Entering in the #15 ADD in onUpgrade");
+                Log_OC.i(SQL, "Entering in the #15 ADD in onUpgrade");
                 db.beginTransaction();
                 try {
                     // drop old capabilities table
@@ -831,37 +839,37 @@ public class FileContentProvider extends ContentProvider {
                 }
             }
 
-            if (!upgraded)
-                Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
-                        ", newVersion == " + newVersion);
-
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
         }
     }
 
     private void createFilesTable(SQLiteDatabase db){
+
         db.execSQL("CREATE TABLE " + ProviderTableMeta.FILE_TABLE_NAME + "("
                         + ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
-                        + ProviderTableMeta.FILE_NAME + " TEXT, "
-                        + ProviderTableMeta.FILE_PATH + " TEXT, "
-                        + ProviderTableMeta.FILE_PARENT + " INTEGER, "
-                        + ProviderTableMeta.FILE_CREATION + " INTEGER, "
-                        + ProviderTableMeta.FILE_MODIFIED + " INTEGER, "
-                        + ProviderTableMeta.FILE_CONTENT_TYPE + " TEXT, "
-                        + ProviderTableMeta.FILE_CONTENT_LENGTH + " INTEGER, "
-                        + ProviderTableMeta.FILE_STORAGE_PATH + " TEXT, "
-                        + ProviderTableMeta.FILE_ACCOUNT_OWNER + " TEXT, "
-                        + ProviderTableMeta.FILE_LAST_SYNC_DATE + " INTEGER, "
-                        + ProviderTableMeta.FILE_KEEP_IN_SYNC + " INTEGER, "
-                        + ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA + " INTEGER, "
-                        + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA + " INTEGER, "
-                        + ProviderTableMeta.FILE_ETAG + " TEXT, "
-                        + ProviderTableMeta.FILE_SHARED_VIA_LINK + " INTEGER, "
-                        + ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT, "
+                        + ProviderTableMeta.FILE_NAME + TEXT
+                        + ProviderTableMeta.FILE_PATH + TEXT
+                        + ProviderTableMeta.FILE_PARENT + INTEGER
+                        + ProviderTableMeta.FILE_CREATION + INTEGER
+                        + ProviderTableMeta.FILE_MODIFIED + INTEGER
+                        + ProviderTableMeta.FILE_CONTENT_TYPE + TEXT
+                        + ProviderTableMeta.FILE_CONTENT_LENGTH + INTEGER
+                        + ProviderTableMeta.FILE_STORAGE_PATH + TEXT
+                        + ProviderTableMeta.FILE_ACCOUNT_OWNER + TEXT
+                        + ProviderTableMeta.FILE_LAST_SYNC_DATE + INTEGER
+                        + ProviderTableMeta.FILE_KEEP_IN_SYNC + INTEGER
+                        + ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA + INTEGER
+                        + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA + INTEGER
+                        + ProviderTableMeta.FILE_ETAG + TEXT
+                        + ProviderTableMeta.FILE_SHARED_VIA_LINK + INTEGER
+                        + ProviderTableMeta.FILE_PUBLIC_LINK + TEXT
                         + ProviderTableMeta.FILE_PERMISSIONS + " TEXT null,"
                         + ProviderTableMeta.FILE_REMOTE_ID + " TEXT null,"
-                        + ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER," //boolean
-                        + ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER," //boolean
-                        + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT,"
+                        + ProviderTableMeta.FILE_UPDATE_THUMBNAIL + INTEGER //boolean
+                        + ProviderTableMeta.FILE_IS_DOWNLOADING + INTEGER //boolean
+                        + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + TEXT
                         + ProviderTableMeta.FILE_SHARED_WITH_SHAREE + " INTEGER);"
         );
     }
@@ -870,19 +878,19 @@ public class FileContentProvider extends ContentProvider {
         // Create ocshares table
         db.execSQL("CREATE TABLE " + ProviderTableMeta.OCSHARES_TABLE_NAME + "("
                 + ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
-                + ProviderTableMeta.OCSHARES_FILE_SOURCE + " INTEGER, "
-                + ProviderTableMeta.OCSHARES_ITEM_SOURCE + " INTEGER, "
-                + ProviderTableMeta.OCSHARES_SHARE_TYPE + " INTEGER, "
-                + ProviderTableMeta.OCSHARES_SHARE_WITH + " TEXT, "
-                + ProviderTableMeta.OCSHARES_PATH + " TEXT, "
-                + ProviderTableMeta.OCSHARES_PERMISSIONS+ " INTEGER, "
-                + ProviderTableMeta.OCSHARES_SHARED_DATE + " INTEGER, "
-                + ProviderTableMeta.OCSHARES_EXPIRATION_DATE + " INTEGER, "
-                + ProviderTableMeta.OCSHARES_TOKEN + " TEXT, "
-                + ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME + " TEXT, "
-                + ProviderTableMeta.OCSHARES_IS_DIRECTORY + " INTEGER, "  // boolean
-                + ProviderTableMeta.OCSHARES_USER_ID + " INTEGER, "
-                + ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + " INTEGER,"
+                + ProviderTableMeta.OCSHARES_FILE_SOURCE + INTEGER
+                + ProviderTableMeta.OCSHARES_ITEM_SOURCE + INTEGER
+                + ProviderTableMeta.OCSHARES_SHARE_TYPE + INTEGER
+                + ProviderTableMeta.OCSHARES_SHARE_WITH + TEXT
+                + ProviderTableMeta.OCSHARES_PATH + TEXT
+                + ProviderTableMeta.OCSHARES_PERMISSIONS+ INTEGER
+                + ProviderTableMeta.OCSHARES_SHARED_DATE + INTEGER
+                + ProviderTableMeta.OCSHARES_EXPIRATION_DATE + INTEGER
+                + ProviderTableMeta.OCSHARES_TOKEN + TEXT
+                + ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME + TEXT
+                + ProviderTableMeta.OCSHARES_IS_DIRECTORY + INTEGER  // boolean
+                + ProviderTableMeta.OCSHARES_USER_ID + INTEGER
+                + ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + INTEGER
                 + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " TEXT );" );
     }
 
@@ -890,28 +898,28 @@ public class FileContentProvider extends ContentProvider {
         // Create capabilities table
         db.execSQL("CREATE TABLE " + ProviderTableMeta.CAPABILITIES_TABLE_NAME + "("
                 + ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
-                + ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + " TEXT, "
-                + ProviderTableMeta.CAPABILITIES_VERSION_MAYOR + " INTEGER, "
-                + ProviderTableMeta.CAPABILITIES_VERSION_MINOR + " INTEGER, "
-                + ProviderTableMeta.CAPABILITIES_VERSION_MICRO + " INTEGER, "
-                + ProviderTableMeta.CAPABILITIES_VERSION_STRING + " TEXT, "
-                + ProviderTableMeta.CAPABILITIES_VERSION_EDITION + " TEXT, "
-                + ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL + " INTEGER, "
-                + ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED + " INTEGER, " // boolean
-                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED + " INTEGER, "  // boolean
-                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED + " INTEGER, "    // boolean
-                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED + " INTEGER, "  // boolean
-                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS + " INTEGER, "
-                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED + " INTEGER, " // boolean
-                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL + " INTEGER, "    // boolean
-                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD + " INTEGER, "       // boolean
-                + ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL + " INTEGER, "      // boolean
-                + ProviderTableMeta.CAPABILITIES_SHARING_RESHARING + " INTEGER, "           // boolean
-                + ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING + " INTEGER, "     // boolean
-                + ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING + " INTEGER, "     // boolean
-                + ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING + " INTEGER, "   // boolean
-                + ProviderTableMeta.CAPABILITIES_FILES_UNDELETE + " INTEGER, "  // boolean
-                + ProviderTableMeta.CAPABILITIES_FILES_VERSIONING + " INTEGER, "   // boolean
+                + ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + TEXT
+                + ProviderTableMeta.CAPABILITIES_VERSION_MAYOR + INTEGER
+                + ProviderTableMeta.CAPABILITIES_VERSION_MINOR + INTEGER
+                + ProviderTableMeta.CAPABILITIES_VERSION_MICRO + INTEGER
+                + ProviderTableMeta.CAPABILITIES_VERSION_STRING + TEXT
+                + ProviderTableMeta.CAPABILITIES_VERSION_EDITION + TEXT
+                + ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL + INTEGER
+                + ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED + INTEGER // boolean
+                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED + INTEGER  // boolean
+                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED + INTEGER    // boolean
+                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED + INTEGER  // boolean
+                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS + INTEGER
+                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED + INTEGER // boolean
+                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL + INTEGER    // boolean
+                + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD + INTEGER       // boolean
+                + ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL + INTEGER      // boolean
+                + ProviderTableMeta.CAPABILITIES_SHARING_RESHARING + INTEGER           // boolean
+                + ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING + INTEGER     // boolean
+                + ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING + INTEGER     // boolean
+                + ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING + INTEGER   // boolean
+                + ProviderTableMeta.CAPABILITIES_FILES_UNDELETE + INTEGER  // boolean
+                + ProviderTableMeta.CAPABILITIES_FILES_VERSIONING + INTEGER   // boolean
                 + ProviderTableMeta.CAPABILITIES_FILES_DROP + " INTEGER );" );   // boolean
     }
 
@@ -919,17 +927,17 @@ public class FileContentProvider extends ContentProvider {
         // Create uploads table
         db.execSQL("CREATE TABLE " + ProviderTableMeta.UPLOADS_TABLE_NAME + "("
                 + ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
-                + ProviderTableMeta.UPLOADS_LOCAL_PATH + " TEXT, "
-                + ProviderTableMeta.UPLOADS_REMOTE_PATH + " TEXT, "
-                + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + " TEXT, "
+                + ProviderTableMeta.UPLOADS_LOCAL_PATH + TEXT
+                + ProviderTableMeta.UPLOADS_REMOTE_PATH + TEXT
+                + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + TEXT
                 + ProviderTableMeta.UPLOADS_FILE_SIZE + " LONG, "
-                + ProviderTableMeta.UPLOADS_STATUS + " INTEGER, "               // UploadStatus
-                + ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR + " INTEGER, "      // Upload LocalBehaviour
-                + ProviderTableMeta.UPLOADS_UPLOAD_TIME + " INTEGER, "
-                + ProviderTableMeta.UPLOADS_FORCE_OVERWRITE + " INTEGER, "  // boolean
-                + ProviderTableMeta.UPLOADS_IS_CREATE_REMOTE_FOLDER + " INTEGER, "  // boolean
-                + ProviderTableMeta.UPLOADS_UPLOAD_END_TIMESTAMP + " INTEGER, "
-                + ProviderTableMeta.UPLOADS_LAST_RESULT + " INTEGER, "     // Upload LastResult
+                + ProviderTableMeta.UPLOADS_STATUS + INTEGER               // UploadStatus
+                + ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR + INTEGER      // Upload LocalBehaviour
+                + ProviderTableMeta.UPLOADS_UPLOAD_TIME + INTEGER
+                + ProviderTableMeta.UPLOADS_FORCE_OVERWRITE + INTEGER  // boolean
+                + ProviderTableMeta.UPLOADS_IS_CREATE_REMOTE_FOLDER + INTEGER  // boolean
+                + ProviderTableMeta.UPLOADS_UPLOAD_END_TIMESTAMP + INTEGER
+                + ProviderTableMeta.UPLOADS_LAST_RESULT + INTEGER     // Upload LastResult
                 + ProviderTableMeta.UPLOADS_CREATED_BY + " INTEGER );"    // Upload createdBy
         );
 
@@ -968,7 +976,7 @@ public class FileContentProvider extends ContentProvider {
      * @param db        Database where table of files is included.
      */
     private void updateAccountName(SQLiteDatabase db){
-        Log_OC.d("SQL", "THREAD:  " + Thread.currentThread().getName());
+        Log_OC.d(SQL, "THREAD:  " + Thread.currentThread().getName());
         AccountManager ama = AccountManager.get(getContext());
         try {
             // get accounts from AccountManager ;  we can't be sure if accounts in it are updated or not although
@@ -994,7 +1002,7 @@ public class FileContentProvider extends ContentProvider {
                             ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
                             new String[]{oldAccountName});
 
-                    Log_OC.d("SQL", "Updated account in database: old name == " + oldAccountName +
+                    Log_OC.d(SQL, "Updated account in database: old name == " + oldAccountName +
                             ", new name == " + newAccountName + " (" + num + " rows updated )");
 
                     // update path for downloaded files
@@ -1061,7 +1069,7 @@ public class FileContentProvider extends ContentProvider {
                             ProviderTableMeta.FILE_STORAGE_PATH + "=?",
                             new String[]{oldPath});
 
-                    Log_OC.v("SQL", "Updated path of downloaded file: old file name == " + oldPath +
+                    Log_OC.v(SQL, "Updated path of downloaded file: old file name == " + oldPath +
                             ", new file name == " + newPath);
 
                 } while (c.moveToNext());
@@ -1080,6 +1088,7 @@ public class FileContentProvider extends ContentProvider {
     private void trimSuccessfulUploads(SQLiteDatabase db) {
         Cursor c = null;
         try {
+            String MAX_SUCCESSFUL_UPLOADS = "30";
             c = db.rawQuery(
                 "delete from " + ProviderTableMeta.UPLOADS_TABLE_NAME +
                     " where " + ProviderTableMeta.UPLOADS_STATUS + " == "

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

@@ -218,14 +218,8 @@ public class OperationsService extends Service {
                     saveAllClients(this, MainApp.getAccountType());
 
             // 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();
+        } catch (AccountNotFoundException | IOException | OperationCanceledException | AuthenticatorException e) {
+            Log_OC.d(TAG, e.getMessage(), e);
         }
 
         mUndispatchedFinishedOperations.clear();

+ 6 - 9
src/com/owncloud/android/services/SyncFolderHandler.java

@@ -52,10 +52,9 @@ class SyncFolderHandler extends Handler {
     private static final String TAG = SyncFolderHandler.class.getSimpleName();
 
 
-    OperationsService mService;
+    private OperationsService mService;
 
-    private IndexedForest<SynchronizeFolderOperation> mPendingOperations =
-            new IndexedForest<SynchronizeFolderOperation>();
+    private IndexedForest<SynchronizeFolderOperation> mPendingOperations = new IndexedForest<>();
 
     private OwnCloudClient mOwnCloudClient = null;
     private Account mCurrentAccount = null;
@@ -80,7 +79,9 @@ class SyncFolderHandler extends Handler {
      * @param remotePath    The path to a folder that could be in the queue of synchronizations.
      */
     public boolean isSynchronizing(Account account, String remotePath) {
-        if (account == null || remotePath == null) return false;
+        if (account == null || remotePath == null) {
+            return false;
+        }
         return (mPendingOperations.contains(account.name, remotePath));
     }
 
@@ -121,9 +122,7 @@ class SyncFolderHandler extends Handler {
 
                 result = mCurrentSyncOperation.execute(mOwnCloudClient, mStorageManager);
 
-            } catch (AccountsException e) {
-                Log_OC.e(TAG, "Error while trying to get authorization", e);
-            } catch (IOException e) {
+            } catch (AccountsException | IOException e) {
                 Log_OC.e(TAG, "Error while trying to get authorization", e);
             } finally {
                 mPendingOperations.removePayload(account.name, remotePath);
@@ -200,6 +199,4 @@ class SyncFolderHandler extends Handler {
         finished.putExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, success);
         mService.sendStickyBroadcast(finished);
     }
-
-
 }

+ 1 - 1
src/com/owncloud/android/services/observer/FileObserverService.java

@@ -68,7 +68,7 @@ public class FileObserverService extends Service {
     private final static String ARG_FILE = "ARG_FILE";
     private final static String ARG_ACCOUNT = "ARG_ACCOUNT";
 
-    private static String TAG = FileObserverService.class.getSimpleName();
+    private static final String TAG = FileObserverService.class.getSimpleName();
 
     private Map<String, FolderObserver> mFolderObserversMap;
     private DownloadCompletedReceiver mDownloadReceiver;

+ 10 - 7
src/com/owncloud/android/services/observer/FolderObserver.java

@@ -52,14 +52,14 @@ import java.util.Map;
  */
 public class FolderObserver extends FileObserver {
 
-    private static String TAG = FolderObserver.class.getSimpleName();
+    private static final String TAG = FolderObserver.class.getSimpleName();
 
-    private static int UPDATE_MASK = (
+    private static final int UPDATE_MASK = (
             FileObserver.ATTRIB | FileObserver.MODIFY | 
             FileObserver.MOVED_TO | FileObserver.CLOSE_WRITE
     ); 
     
-    private static int IN_IGNORE = 32768;
+    private static final int IN_IGNORE = 32768;
     /* 
     private static int ALL_EVENTS_EVEN_THOSE_NOT_DOCUMENTED = 0x7fffffff;   // NEVER use 0xffffffff
     */
@@ -67,7 +67,7 @@ public class FolderObserver extends FileObserver {
     private String mPath;
     private Account mAccount;
     private Context mContext;
-    private Map<String, Boolean> mObservedChildren;
+    private final Map<String, Boolean> mObservedChildren;
 
     /**
      * Constructor.
@@ -82,12 +82,15 @@ public class FolderObserver extends FileObserver {
     public FolderObserver(String path, Account account, Context context) {
         super(path, UPDATE_MASK);
         
-        if (path == null)
+        if (path == null) {
             throw new IllegalArgumentException("NULL path argument received");
-        if (account == null)
+        }
+        if (account == null) {
             throw new IllegalArgumentException("NULL account argument received");
-        if (context == null)
+        }
+        if (context == null) {
             throw new IllegalArgumentException("NULL context argument received");
+        }
         
         mPath = path;
         mAccount = account;

+ 13 - 18
src/com/owncloud/android/syncadapter/FileSyncAdapter.java

@@ -89,11 +89,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
     
     /** Flag made 'true' when a request to cancel the synchronization is received */
     private boolean mCancellation;
-    
-    /** When 'true' the process was requested by the user through the user interface;
-     *  when 'false', it was requested automatically by the system */
-    private boolean mIsManualSync;
-    
+
     /** Counter for failed operations in the synchronization process */
     private int mFailedResultsCounter;
     
@@ -146,7 +142,9 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             SyncResult syncResult) {
 
         mCancellation = false;
-        mIsManualSync = extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false);
+        /* When 'true' the process was requested by the user through the user interface;
+       when 'false', it was requested automatically by the system */
+        boolean mIsManualSync = extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false);
         mFailedResultsCounter = 0;
         mLastFailedResult = null;
         mConflictsFound = 0;
@@ -162,20 +160,14 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
         
         try {
             this.initClientForCurrentAccount();
-        } catch (IOException e) {
-            /// the account is unknown for the Synchronization Manager, unreachable this context,
-            // or can not be authenticated; don't try this again
-            mSyncResult.tooManyRetries = true;
-            notifyFailedSynchronization();
-            return;
-        } catch (AccountsException e) {
+        } catch (IOException | AccountsException e) {
             /// the account is unknown for the Synchronization Manager, unreachable this context,
             // or can not be authenticated; don't try this again
             mSyncResult.tooManyRetries = true;
             notifyFailedSynchronization();
             return;
         }
-        
+
         Log_OC.d(TAG, "Synchronization of ownCloud account " + account.name + " starting");
         sendLocalBroadcast(EVENT_FULL_SYNC_START, null, null);  // message to signal the start
                                                                 // of the synchronization to the UI
@@ -262,8 +254,9 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
      */
     private void synchronizeFolder(OCFile folder) {
         
-        if (mFailedResultsCounter > MAX_FAILED_RESULTS || isFinisher(mLastFailedResult))
+        if (mFailedResultsCounter > MAX_FAILED_RESULTS || isFinisher(mLastFailedResult)) {
             return;
+        }
         
         // folder synchronization
         RefreshFolderOperation synchFolderOp = new RefreshFolderOperation( folder,
@@ -355,9 +348,11 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             }
         }
        
-        if (mCancellation && i <files.size()) Log_OC.d(TAG,
-                "Leaving synchronization before synchronizing " + files.get(i).getRemotePath() +
-                        " due to cancelation request");
+        if (mCancellation && i <files.size()) {
+            Log_OC.d(TAG,
+                    "Leaving synchronization before synchronizing " + files.get(i).getRemotePath() +
+                            " due to cancelation request");
+        }
     }
 
     

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

@@ -39,7 +39,7 @@ import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionM
  */
 public class ConflictsResolveActivity extends FileActivity implements OnConflictDecisionMadeListener {
 
-    private String TAG = ConflictsResolveActivity.class.getSimpleName();
+    private static final String TAG = ConflictsResolveActivity.class.getSimpleName();
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {

+ 44 - 47
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -175,7 +175,7 @@ public class FileDisplayActivity extends HookActivity
         setupToolbar();
 
         // setup drawer
-        if(MainApp.getOnlyOnDevice()) {
+        if(MainApp.isOnlyOnDevice()) {
             setupDrawer(R.id.nav_on_device);
         } else {
             setupDrawer(R.id.nav_all_files);
@@ -302,6 +302,7 @@ public class FileDisplayActivity extends HookActivity
                     // toggle on is save since this is the only scenario this code gets accessed
                 } else {
                     // permission denied --> do nothing
+                    return;
                 }
                 return;
             }
@@ -347,8 +348,9 @@ public class FileDisplayActivity extends HookActivity
                     // cache until the upload is successful get parent from path
                     parentPath = file.getRemotePath().substring(0,
                             file.getRemotePath().lastIndexOf(file.getFileName()));
-                    if (getStorageManager().getFileByPath(parentPath) == null)
+                    if (getStorageManager().getFileByPath(parentPath) == null) {
                         file = null; // not able to know the directory where the file is uploading
+                    }
                 } else {
                     file = getStorageManager().getFileByPath(file.getRemotePath());
                     // currentDir = null if not in the current Account
@@ -393,7 +395,7 @@ public class FileDisplayActivity extends HookActivity
             /// First fragment
             OCFileListFragment listOfFiles = getListOfFilesFragment();
             if (listOfFiles != null) {
-                listOfFiles.listDirectory(getCurrentDir(), MainApp.getOnlyOnDevice());
+                listOfFiles.listDirectory(getCurrentDir(), MainApp.isOnlyOnDevice());
             } else {
                 Log_OC.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
             }
@@ -407,8 +409,9 @@ public class FileDisplayActivity extends HookActivity
                 updateActionBarTitleAndHomeButton(file);
             } else {
                 cleanSecondFragment();
-                if (file.isDown() && PreviewTextFragment.canBePreviewed(file))
+                if (file.isDown() && PreviewTextFragment.canBePreviewed(file)) {
                     startTextPreview(file);
+                }
             }
 
         } else {
@@ -521,7 +524,7 @@ public class FileDisplayActivity extends HookActivity
     protected void refreshListOfFilesFragment() {
         OCFileListFragment fileListFragment = getListOfFilesFragment();
         if (fileListFragment != null) {
-            fileListFragment.listDirectory(MainApp.getOnlyOnDevice());
+            fileListFragment.listDirectory(MainApp.isOnlyOnDevice());
         }
     }
 
@@ -530,7 +533,7 @@ public class FileDisplayActivity extends HookActivity
         FileFragment secondFragment = getSecondFragment();
         boolean waitedPreview = (mWaitingToPreview != null &&
                 mWaitingToPreview.getRemotePath().equals(downloadedRemotePath));
-        if (secondFragment != null && secondFragment instanceof FileDetailFragment) {
+        if (secondFragment instanceof FileDetailFragment) {
             FileDetailFragment detailsFragment = (FileDetailFragment) secondFragment;
             OCFile fileInFragment = detailsFragment.getFile();
             if (fileInFragment != null &&
@@ -733,7 +736,6 @@ public class FileDisplayActivity extends HookActivity
         } else if (requestCode == REQUEST_CODE__COPY_FILES && resultCode == RESULT_OK) {
 
             final Intent fData = data;
-            final int fResultCode = resultCode;
             getHandler().postDelayed(
                     new Runnable() {
                         @Override
@@ -1032,12 +1034,11 @@ public class FileDisplayActivity extends HookActivity
                                 currentFile = currentDir;
                             }
 
-                            if (synchFolderRemotePath != null &&
-                                    currentDir.getRemotePath().equals(synchFolderRemotePath)) {
+                            if (currentDir.getRemotePath().equals(synchFolderRemotePath)) {
                                 OCFileListFragment fileListFragment = getListOfFilesFragment();
                                 if (fileListFragment != null) {
                                     fileListFragment.listDirectory(currentDir,
-                                    MainApp.getOnlyOnDevice());
+                                    MainApp.isOnlyOnDevice());
                                 }
                             }
                             setFile(currentFile);
@@ -1048,23 +1049,22 @@ public class FileDisplayActivity extends HookActivity
                                         .equals(event));
 
                         if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
-                            equals(event)) {
+                                equals(event) &&
+                                synchResult != null && !synchResult.isSuccess()) {
 
-                            if (synchResult != null && !synchResult.isSuccess()) {
-                                /// TODO refactor and make common
+                            /// TODO refactor and make common
 
-                                if (checkForRemoteOperationError(synchResult)) {
+                            if (checkForRemoteOperationError(synchResult)) {
 
-                                    requestCredentialsUpdate(context);
+                                requestCredentialsUpdate(context);
 
-                                } else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(
+                            } else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(
                                     synchResult.getCode())) {
 
-                                    showUntrustedCertDialog(synchResult);
-                                }
-
+                                showUntrustedCertDialog(synchResult);
                             }
 
+
                         }
                         removeStickyBroadcast(intent);
                         Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
@@ -1074,11 +1074,9 @@ public class FileDisplayActivity extends HookActivity
                     }
                 }
 
-                if (synchResult != null) {
-                    if (synchResult.getCode().equals(
-                            RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
-                        mLastSslUntrustedServerResult = synchResult;
-                    }
+                if (synchResult != null && synchResult.getCode().equals(
+                        RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
+                    mLastSslUntrustedServerResult = synchResult;
                 }
             } catch (RuntimeException e) {
                 // avoid app crashes after changing the serial id of RemoteOperationResult
@@ -1149,14 +1147,14 @@ public class FileDisplayActivity extends HookActivity
                 boolean sameFile = getFile().getRemotePath().equals(uploadedRemotePath) ||
                         renamedInUpload;
                 FileFragment details = getSecondFragment();
-                boolean detailFragmentIsShown = (details != null &&
-                        details instanceof FileDetailFragment);
+                boolean detailFragmentIsShown = (details instanceof FileDetailFragment);
 
                 if (sameAccount && sameFile && detailFragmentIsShown) {
                     if (uploadWasFine) {
                         setFile(getStorageManager().getFileByPath(uploadedRemotePath));
                     } else {
                         //TODO remove upload progress bar after upload failed.
+                        Log_OC.d(TAG, "Remove upload progress bar after upload failed");
                     }
                     if (renamedInUpload) {
                         String newName = (new File(uploadedRemotePath)).getName();
@@ -1177,10 +1175,12 @@ public class FileDisplayActivity extends HookActivity
                     // Force the preview if the file is an image or text file
                     if (uploadWasFine) {
                         OCFile ocFile = getFile();
-                        if (PreviewImageFragment.canBePreviewed(ocFile))
+                        if (PreviewImageFragment.canBePreviewed(ocFile)) {
                             startImagePreview(getFile());
-                        else if (PreviewTextFragment.canBePreviewed(ocFile))
+                        }
+                        else if (PreviewTextFragment.canBePreviewed(ocFile)) {
                             startTextPreview(ocFile);
+                        }
                         // TODO what about other kind of previews?
                     }
                 }
@@ -1280,7 +1280,7 @@ public class FileDisplayActivity extends HookActivity
         OCFileListFragment listOfFiles = getListOfFilesFragment();
         if (listOfFiles != null) {  // should never be null, indeed
             OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
-            listOfFiles.listDirectory(root, MainApp.getOnlyOnDevice());
+            listOfFiles.listDirectory(root, MainApp.isOnlyOnDevice());
             setFile(listOfFiles.getCurrentFile());
             startSyncFolderOperation(root, false);
         }
@@ -1346,15 +1346,14 @@ public class FileDisplayActivity extends HookActivity
                     FileDisplayActivity.this, FileDownloader.class))) {
                 Log_OC.d(TAG, "Download service connected");
                 mDownloaderBinder = (FileDownloaderBinder) service;
-                if (mWaitingToPreview != null)
-                    if (getStorageManager() != null) {
-                        // update the file
-                        mWaitingToPreview =
-                                getStorageManager().getFileById(mWaitingToPreview.getFileId());
-                        if (!mWaitingToPreview.isDown()) {
-                            requestForDownload();
-                        }
+                if (mWaitingToPreview != null && getStorageManager() != null) {
+                    // update the file
+                    mWaitingToPreview =
+                            getStorageManager().getFileById(mWaitingToPreview.getFileId());
+                    if (!mWaitingToPreview.isDown()) {
+                        requestForDownload();
                     }
+                }
 
             } else if (component.equals(new ComponentName(FileDisplayActivity.this,
                     FileUploader.class))) {
@@ -1367,10 +1366,10 @@ public class FileDisplayActivity extends HookActivity
             // getFileDownloadBinder() - THIS IS A MESS
             OCFileListFragment listOfFiles = getListOfFilesFragment();
             if (listOfFiles != null) {
-                listOfFiles.listDirectory(MainApp.getOnlyOnDevice());
+                listOfFiles.listDirectory(MainApp.isOnlyOnDevice());
             }
             FileFragment secondFragment = getSecondFragment();
-            if (secondFragment != null && secondFragment instanceof FileDetailFragment) {
+            if (secondFragment instanceof FileDetailFragment) {
                 FileDetailFragment detailFragment = (FileDetailFragment) secondFragment;
                 detailFragment.listenForTransferProgress();
                 detailFragment.updateFileDetails(false, false);
@@ -1585,13 +1584,11 @@ public class FileDisplayActivity extends HookActivity
 
     private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation,
                                                   RemoteOperationResult result) {
-        if (result.isSuccess()) {
-            if (operation.transferWasRequested()) {
-                OCFile syncedFile = operation.getLocalFile();
-                onTransferStateChanged(syncedFile, true, true);
-                invalidateOptionsMenu();
-                refreshShowDetails();
-            }
+        if (result.isSuccess() && operation.transferWasRequested()) {
+            OCFile syncedFile = operation.getLocalFile();
+            onTransferStateChanged(syncedFile, true, true);
+            invalidateOptionsMenu();
+            refreshShowDetails();
         }
     }
 
@@ -1627,7 +1624,7 @@ public class FileDisplayActivity extends HookActivity
     public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) {
         refreshListOfFilesFragment();
         FileFragment details = getSecondFragment();
-        if (details != null && details instanceof FileDetailFragment &&
+        if (details instanceof FileDetailFragment &&
                 file.equals(details.getFile())) {
             if (downloading || uploading) {
                 ((FileDetailFragment) details).updateFileDetails(file, getAccount());

+ 3 - 4
src/com/owncloud/android/ui/activity/FolderPickerActivity.java

@@ -363,9 +363,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
     
     @Override
     public void onClick(View v) {
-        if (v == mCancelBtn) {
+        if (v.equals(mCancelBtn)) {
             finish();
-        } else if (v == mChooseBtn) {
+        } else if (v.equals(mChooseBtn)) {
             Intent i = getIntent();
             ArrayList<Parcelable> targetFiles = i.getParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES);
 
@@ -462,8 +462,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
                                 currentFile = currentDir;
                             }
 
-                            if (synchFolderRemotePath != null && currentDir.getRemotePath().
-                                    equals(synchFolderRemotePath)) {
+                            if (currentDir.getRemotePath().equals(synchFolderRemotePath)) {
                                 OCFileListFragment fileListFragment = getListOfFilesFragment();
                                 if (fileListFragment != null) {
                                     fileListFragment.listDirectory(currentDir, false);

+ 5 - 7
src/com/owncloud/android/ui/activity/GenericExplanationActivity.java

@@ -105,13 +105,11 @@ public class GenericExplanationActivity  extends AppCompatActivity {
         @Override
         public View getView (int position, View convertView, ViewGroup parent) {
             View view = super.getView(position, convertView, parent);
-            if (view != null)  {
-                if (mList2 != null && mList2.size() > 0 && position >= 0 &&
-                        position < mList2.size()) {
-                    TextView text2 = (TextView) view.findViewById(android.R.id.text2);
-                    if (text2 != null) {
-                        text2.setText(mList2.get(position));
-                    }
+            if (mList2 != null && mList2.size() > 0 && position >= 0 &&
+                    position < mList2.size()) {
+                TextView text2 = (TextView) view.findViewById(android.R.id.text2);
+                if (text2 != null) {
+                    text2.setText(mList2.get(position));
                 }
             }
             return view;

+ 7 - 4
src/com/owncloud/android/ui/activity/LogHistoryActivity.java

@@ -43,8 +43,10 @@ import com.owncloud.android.utils.FileStorageUtils;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.lang.ref.WeakReference;
 import java.lang.reflect.Field;
 import java.util.ArrayList;
@@ -200,7 +202,7 @@ public class LogHistoryActivity extends ToolbarActivity {
         }
 
         protected void onPostExecute(String result) {
-            if (textViewReference != null && result != null) {
+            if (result != null) {
                 final TextView logTV = textViewReference.get();
                 if (logTV != null) {
                     mLogText = result;
@@ -228,8 +230,9 @@ public class LogHistoryActivity extends ToolbarActivity {
                     File file = new File(mLogPath,logFileName[i]);
                     if (file.exists()) {
                         // Check if FileReader is ready
-                        if (new FileReader(file).ready()) {
-                            br = new BufferedReader(new FileReader(file));
+                        final InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(file), "UTF8");
+                        if (inputStreamReader.ready()) {
+                            br = new BufferedReader(inputStreamReader);
                             while ((line = br.readLine()) != null) {
                                 // Append the log info
                                 text.append(line);
@@ -240,7 +243,7 @@ public class LogHistoryActivity extends ToolbarActivity {
                 }
             }
             catch (IOException e) {
-                Log_OC.d(TAG, e.getMessage().toString());
+                Log_OC.d(TAG, e.getMessage());
                 
             } finally {
                 if (br != null) {

+ 0 - 8
src/com/owncloud/android/ui/activity/ManageAccountsActivity.java

@@ -75,8 +75,6 @@ public class ManageAccountsActivity extends FileActivity
     private final Handler mHandler = new Handler();
     private String mAccountName;
     private AccountListAdapter mAccountListAdapter;
-    protected FileUploader.FileUploaderBinder mUploaderBinder = null;
-    protected FileDownloader.FileDownloaderBinder mDownloaderBinder = null;
     private ServiceConnection mDownloadServiceConnection, mUploadServiceConnection = null;
     Set<String> mOriginalAccounts;
     String mOriginalCurrentAccount;
@@ -329,12 +327,6 @@ public class ManageAccountsActivity extends FileActivity
 
     public Handler getHandler() { return mHandler; }
 
-    // Methods for ComponentsGetter
-    @Override
-    public FileDownloader.FileDownloaderBinder getFileDownloaderBinder() {
-        return mDownloaderBinder;
-    }
-
     @Override
     public FileUploader.FileUploaderBinder getFileUploaderBinder() {
         return mUploaderBinder;

+ 8 - 5
src/com/owncloud/android/ui/activity/PassCodeActivity.java

@@ -70,9 +70,9 @@ public class PassCodeActivity extends AppCompatActivity {
     private EditText[] mPassCodeEditTexts = new EditText[4];
 
     private String [] mPassCodeDigits = {"","","",""};
-    private static String KEY_PASSCODE_DIGITS = "PASSCODE_DIGITS";
+    private static final String KEY_PASSCODE_DIGITS = "PASSCODE_DIGITS";
     private boolean mConfirmingPassCode = false;
-    private static String KEY_CONFIRMING_PASSCODE = "CONFIRMING_PASSCODE";
+    private static final String KEY_CONFIRMING_PASSCODE = "CONFIRMING_PASSCODE";
 
     private boolean mBChange = true; // to control that only one blocks jump
 
@@ -185,8 +185,9 @@ public class PassCodeActivity extends AppCompatActivity {
                 // used to control what's exactly happening with DEL, not any custom field...
                     mPassCodeEditTexts[0].setText("");
                     mPassCodeEditTexts[0].requestFocus();
-                    if (!mConfirmingPassCode)
+                    if (!mConfirmingPassCode) {
                         mPassCodeDigits[0] = "";
+                    }
                     mBChange = false;
 
                 } else if (!mBChange) {
@@ -221,8 +222,9 @@ public class PassCodeActivity extends AppCompatActivity {
             public boolean onKey(View v, int keyCode, KeyEvent event) {
                 if (keyCode == KeyEvent.KEYCODE_DEL && mBChange) {
                     mPassCodeEditTexts[1].requestFocus();
-                    if (!mConfirmingPassCode)
+                    if (!mConfirmingPassCode) {
                         mPassCodeDigits[1] = "";
+                    }
                     mPassCodeEditTexts[1].setText("");
                     mBChange = false;
 
@@ -258,8 +260,9 @@ public class PassCodeActivity extends AppCompatActivity {
             public boolean onKey(View v, int keyCode, KeyEvent event) {
                 if (keyCode == KeyEvent.KEYCODE_DEL && mBChange) {
                     mPassCodeEditTexts[2].requestFocus();
-                    if (!mConfirmingPassCode)
+                    if (!mConfirmingPassCode) {
                         mPassCodeDigits[2] = "";
+                    }
                     mPassCodeEditTexts[2].setText("");
                     mBChange = false;
 

+ 28 - 31
src/com/owncloud/android/ui/activity/Preferences.java

@@ -112,7 +112,7 @@ public class Preferences extends PreferenceActivity
     private ListPreference mPrefStoragePath;
     private String mStoragePath;
 
-    public static class Keys {
+    public static class PreferenceKeys {
         public static final String STORAGE_PATH = "storage_path";
         public static final String INSTANT_UPLOAD_PATH = "instant_upload_path";
         public static final String INSTANT_VIDEO_UPLOAD_PATH = "instant_video_upload_path";
@@ -223,7 +223,7 @@ public class Preferences extends PreferenceActivity
                 pHelp.setOnPreferenceClickListener(new OnPreferenceClickListener() {
                     @Override
                     public boolean onPreferenceClick(Preference preference) {
-                        String helpWeb = (String) getText(R.string.url_help);
+                        String helpWeb = getString(R.string.url_help);
                         if (helpWeb != null && helpWeb.length() > 0) {
                             Uri uriUrl = Uri.parse(helpWeb);
                             Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
@@ -253,11 +253,8 @@ public class Preferences extends PreferenceActivity
                         String appName = getString(R.string.app_name);
                         String downloadUrl = getString(R.string.url_app_download);
 
-                        String recommendSubject =
-                                String.format(getString(R.string.recommend_subject),
-                                        appName);
-                        String recommendText = String.format(getString(R.string.recommend_text),
-                                appName, downloadUrl);
+                        String recommendSubject = String.format(getString(R.string.recommend_subject), appName);
+                        String recommendText = String.format(getString(R.string.recommend_text), appName, downloadUrl);
 
                         intent.putExtra(Intent.EXTRA_SUBJECT, recommendSubject);
                         intent.putExtra(Intent.EXTRA_TEXT, recommendText);
@@ -279,9 +276,8 @@ public class Preferences extends PreferenceActivity
                 pFeedback.setOnPreferenceClickListener(new OnPreferenceClickListener() {
                     @Override
                     public boolean onPreferenceClick(Preference preference) {
-                        String feedbackMail = (String) getText(R.string.mail_feedback);
-                        String feedback = (String) getText(R.string.prefs_feedback) +
-                                " - android v" + appVersion;
+                        String feedbackMail = getString(R.string.mail_feedback);
+                        String feedback = getText(R.string.prefs_feedback) + " - android v" + appVersion;
                         Intent intent = new Intent(Intent.ACTION_SENDTO);
                         intent.setType("text/plain");
                         intent.putExtra(Intent.EXTRA_SUBJECT, feedback);
@@ -323,7 +319,7 @@ public class Preferences extends PreferenceActivity
                 pImprint.setOnPreferenceClickListener(new OnPreferenceClickListener() {
                     @Override
                     public boolean onPreferenceClick(Preference preference) {
-                        String imprintWeb = (String) getText(R.string.url_imprint);
+                        String imprintWeb = getString(R.string.url_imprint);
                         if (imprintWeb != null && imprintWeb.length() > 0) {
                             Uri uriUrl = Uri.parse(imprintWeb);
                             Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
@@ -338,7 +334,7 @@ public class Preferences extends PreferenceActivity
             }
         }
 
-        mPrefStoragePath = (ListPreference) findPreference(Keys.STORAGE_PATH);
+        mPrefStoragePath = (ListPreference) findPreference(PreferenceKeys.STORAGE_PATH);
         if (mPrefStoragePath != null) {
             StoragePoint[] storageOptions = DataStorageProvider.getInstance().getAvailableStoragePoints();
             String[] entries = new String[storageOptions.length];
@@ -351,11 +347,12 @@ public class Preferences extends PreferenceActivity
             mPrefStoragePath.setEntryValues(values);
 
             mPrefStoragePath.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
-                @Override
-                public boolean onPreferenceChange(Preference preference, Object newValue) {
-                    String newPath = (String) newValue;
-                    if (mStoragePath.equals(newPath))
-                        return true;
+                    @Override
+                    public boolean onPreferenceChange(Preference preference, Object newValue) {
+                        String newPath = (String) newValue;
+                        if (mStoragePath.equals(newPath)) {
+                            return true;
+                        }
 
                     StorageMigration storageMigration = new StorageMigration(Preferences.this, mStoragePath, newPath);
 
@@ -390,8 +387,7 @@ public class Preferences extends PreferenceActivity
                 });
             }
 
-            mPrefInstantUploadCategory =
-                    (PreferenceCategory) findPreference("instant_uploading_category");
+        mPrefInstantUploadCategory = (PreferenceCategory) findPreference("instant_uploading_category");
 
             mPrefInstantUploadUseSubfolders = findPreference("instant_upload_path_use_subfolders");
             mPrefInstantUploadPathWiFi = findPreference("instant_upload_on_wifi");
@@ -412,8 +408,8 @@ public class Preferences extends PreferenceActivity
                 }
             });
 
-            mPrefInstantVideoUploadPath = findPreference(Keys.INSTANT_VIDEO_UPLOAD_PATH);
-            if (mPrefInstantVideoUploadPath != null) {
+        mPrefInstantVideoUploadPath = findPreference(PreferenceKeys.INSTANT_VIDEO_UPLOAD_PATH);
+        if (mPrefInstantVideoUploadPath != null){
 
                 mPrefInstantVideoUploadPath.setOnPreferenceClickListener(new OnPreferenceClickListener() {
                     @Override
@@ -525,7 +521,7 @@ public class Preferences extends PreferenceActivity
     }
     
     private void toggleInstantPictureOptions(Boolean value){
-        if (value){
+        if (value) {
             mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPathWiFi);
             mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPath);
             mPrefInstantUploadCategory.addPreference(mPrefInstantUploadUseSubfolders);
@@ -539,7 +535,7 @@ public class Preferences extends PreferenceActivity
     }
 
     private void toggleInstantVideoOptions(Boolean value){
-        if (value){
+        if (value) {
             mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPathWiFi);
             mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPath);
             mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadUseSubfolders);
@@ -553,7 +549,7 @@ public class Preferences extends PreferenceActivity
     }
 
     private void toggleInstantUploadBehaviour(Boolean video, Boolean picture){
-        if (picture || video){
+        if (picture || video) {
             mPrefInstantUploadCategory.addPreference(mPrefInstantUploadBehaviour);
         } else {
             mPrefInstantUploadCategory.removePreference(mPrefInstantUploadBehaviour);
@@ -597,7 +593,7 @@ public class Preferences extends PreferenceActivity
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
-        if (requestCode == ACTION_SELECT_UPLOAD_PATH && resultCode == RESULT_OK){
+        if (requestCode == ACTION_SELECT_UPLOAD_PATH && resultCode == RESULT_OK) {
 
             OCFile folderToUpload =  data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER);
 
@@ -734,7 +730,7 @@ public class Preferences extends PreferenceActivity
     private void loadInstantUploadPath() {
         SharedPreferences appPrefs =
                 PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
-        mUploadPath = appPrefs.getString(Keys.INSTANT_UPLOAD_PATH, getString(R.string.instant_upload_path));
+        mUploadPath = appPrefs.getString(PreferenceKeys.INSTANT_UPLOAD_PATH, getString(R.string.instant_upload_path));
         mPrefInstantUploadPath.setSummary(mUploadPath);
     }
 
@@ -747,7 +743,7 @@ public class Preferences extends PreferenceActivity
         mStoragePath = newStoragePath;
         MainApp.setStoragePath(mStoragePath);
         SharedPreferences.Editor editor = appPrefs.edit();
-        editor.putString(Keys.STORAGE_PATH, mStoragePath);
+        editor.putString(PreferenceKeys.STORAGE_PATH, mStoragePath);
         editor.commit();
         String storageDescription = DataStorageProvider.getInstance().getStorageDescriptionByPath(mStoragePath);
         mPrefStoragePath.setSummary(storageDescription);
@@ -760,7 +756,7 @@ public class Preferences extends PreferenceActivity
     private void loadStoragePath() {
         SharedPreferences appPrefs =
                 PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
-        mStoragePath = appPrefs.getString(Keys.STORAGE_PATH, Environment.getExternalStorageDirectory()
+        mStoragePath = appPrefs.getString(PreferenceKeys.STORAGE_PATH, Environment.getExternalStorageDirectory()
                                                          .getAbsolutePath());
         String storageDescription = DataStorageProvider.getInstance().getStorageDescriptionByPath(mStoragePath);
         mPrefStoragePath.setSummary(storageDescription);
@@ -773,7 +769,7 @@ public class Preferences extends PreferenceActivity
         SharedPreferences appPrefs =
                 PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
         SharedPreferences.Editor editor = appPrefs.edit();
-        editor.putString(Keys.INSTANT_UPLOAD_PATH, mUploadPath);
+        editor.putString(PreferenceKeys.INSTANT_UPLOAD_PATH, mUploadPath);
         editor.commit();
     }
 
@@ -794,14 +790,15 @@ public class Preferences extends PreferenceActivity
         SharedPreferences appPrefs =
                 PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
         SharedPreferences.Editor editor = appPrefs.edit();
-        editor.putString(Keys.INSTANT_VIDEO_UPLOAD_PATH, mUploadVideoPath);
+        editor.putString(PreferenceKeys.INSTANT_VIDEO_UPLOAD_PATH, mUploadVideoPath);
         editor.commit();
     }
 
     @Override
     public void onStorageMigrationFinished(String storagePath, boolean succeed) {
-        if (succeed)
+        if (succeed) {
             saveStoragePath(storagePath);
+        }
     }
 
     @Override

+ 13 - 11
src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

@@ -60,7 +60,6 @@ import com.owncloud.android.authentication.AccountAuthenticator;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.db.PreferenceManager;
 import com.owncloud.android.files.services.FileUploader;
-import com.owncloud.android.lib.common.OwnCloudAccount;
 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;
@@ -266,7 +265,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
         case DIALOG_MULTIPLE_ACCOUNT:
             Account accounts[] = mAccountManager.getAccountsByType(MainApp.getAccountType());
             CharSequence dialogItems[] = new CharSequence[accounts.length];
-            OwnCloudAccount oca;
             for (int i = 0; i < dialogItems.length; ++i) {
                 dialogItems[i] = DisplayUtils.getAccountNameDisplayText(
                         this, accounts[i], accounts[i].name, DisplayUtils.convertIdn(accounts[i].name, false));
@@ -316,11 +314,14 @@ public class ReceiveExternalFilesActivity extends FileActivity
         Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile , false);
         sortFileList(tmpfiles);
 
-        if (tmpfiles.size() <= 0) return;
+        if (tmpfiles.size() <= 0) {
+            return;
+        }
         // filter on dirtype
         Vector<OCFile> files = new Vector<>();
-        for (OCFile f : tmpfiles)
-                files.add(f);
+        for (OCFile f : tmpfiles) {
+            files.add(f);
+        }
         if (files.size() < position) {
             throw new IndexOutOfBoundsException("Incorrect item selected");
         }
@@ -361,7 +362,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
                                             PrintWriter out;
                                             try {
                                                 File f = File.createTempFile("nextcloud", TEXT_FILE_SUFFIX);
-                                                out = new PrintWriter(f);
+                                                out = new PrintWriter(f, "UTF8");
                                                 out.println(getIntent().getStringExtra(Intent.EXTRA_TEXT));
                                                 out.close();
 
@@ -526,8 +527,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
     private String generatePath(Stack<String> dirs) {
         String full_path = "";
 
-        for (String a : dirs)
+        for (String a : dirs) {
             full_path += a + "/";
+        }
         return full_path;
     }
 
@@ -612,7 +614,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
                                                RemoteOperationResult result) {
         if (result.isSuccess()) {
             String remotePath = operation.getRemotePath().substring(0, operation.getRemotePath().length() - 1);
-            String newFolder = remotePath.substring(remotePath.lastIndexOf("/") + 1);
+            String newFolder = remotePath.substring(remotePath.lastIndexOf('/') + 1);
             mParents.push(newFolder);
             populateDirectoryList();
         } else {
@@ -647,8 +649,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
         } else {
             String[] dir_names = lastPath.split("/");
             mParents.clear();
-            for (String dir : dir_names)
+            for (String dir : dir_names) {
                 mParents.add(dir);
+            }
         }
         //Make sure that path still exists, if it doesn't pop the stack and try the previous path
         while (!getStorageManager().fileExists(generatePath(mParents)) && mParents.size() > 1) {
@@ -752,8 +755,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
                                 currentFile = currentDir;
                             }
 
-                            if (synchFolderRemotePath != null &&
-                                    currentDir.getRemotePath().equals(synchFolderRemotePath)) {
+                            if (currentDir.getRemotePath().equals(synchFolderRemotePath)) {
                                 populateDirectoryList();
                             }
                             mFile = currentFile;

+ 43 - 33
src/com/owncloud/android/ui/activity/StorageMigration.java

@@ -45,18 +45,17 @@ import java.io.File;
 public class StorageMigration {
     private static final String TAG = StorageMigration.class.getName();
 
-    public interface StorageMigrationProgressListener {
-        void onStorageMigrationFinished(String storagePath, boolean succeed);
-        void onCancelMigration();
-    }
-
-    private ProgressDialog mProgressDialog;
     private Context mContext;
     private String mSourceStoragePath;
     private String mTargetStoragePath;
 
     private StorageMigrationProgressListener mListener;
 
+    public interface StorageMigrationProgressListener {
+        void onStorageMigrationFinished(String storagePath, boolean succeed);
+        void onCancelMigration();
+    }
+
     public StorageMigration(Context context, String sourcePath, String targetPath) {
         mContext = context;
         mSourceStoragePath = sourcePath;
@@ -68,9 +67,9 @@ public class StorageMigration {
     }
 
     public void migrate() {
-        if (storageFolderAlreadyExists())
+        if (storageFolderAlreadyExists()) {
             askToOverride();
-        else {
+        } else {
             ProgressDialog progressDialog = createMigrationProgressDialog();
             progressDialog.show();
             new FileMigrationTask(
@@ -80,7 +79,7 @@ public class StorageMigration {
                     progressDialog,
                     mListener).execute();
 
-            progressDialog.getButton(progressDialog.BUTTON_POSITIVE).setVisibility(View.GONE);
+            progressDialog.getButton(ProgressDialog.BUTTON_POSITIVE).setVisibility(View.GONE);
         }
     }
 
@@ -97,15 +96,17 @@ public class StorageMigration {
                 .setOnCancelListener(new DialogInterface.OnCancelListener() {
                     @Override
                     public void onCancel(DialogInterface dialogInterface) {
-                        if (mListener != null)
+                        if (mListener != null) {
                             mListener.onCancelMigration();
+                        }
                     }
                 })
                 .setNegativeButton(R.string.common_cancel, new OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialogInterface, int i) {
-                        if (mListener != null)
+                        if (mListener != null) {
                             mListener.onCancelMigration();
+                        }
                     }
                 })
                 .setNeutralButton(R.string.file_migration_use_data_folder, new OnClickListener() {
@@ -160,7 +161,7 @@ public class StorageMigration {
         return progressDialog;
     }
 
-    abstract static private class FileMigrationTaskBase extends AsyncTask<Void, Integer, Integer> {
+    private static abstract class FileMigrationTaskBase extends AsyncTask<Void, Integer, Integer> {
         protected String mStorageSource;
         protected String mStorageTarget;
         protected Context mContext;
@@ -289,7 +290,7 @@ public class StorageMigration {
                 this.mResId = resId;
             }
 
-            int getResId() { return mResId; }
+            private int getResId() { return mResId; }
         }
 
         public FileMigrationTask(Context context,
@@ -351,44 +352,50 @@ public class StorageMigration {
         }
 
 
-        void checkDestinationAvailability() throws MigrationException {
+        private void checkDestinationAvailability() throws MigrationException {
             File srcFile = new File(mStorageSource);
             File dstFile = new File(mStorageTarget);
 
-            if (!dstFile.canRead() || !srcFile.canRead())
+            if (!dstFile.canRead() || !srcFile.canRead()) {
                 throw new MigrationException(R.string.file_migration_failed_not_readable);
+            }
 
-            if (!dstFile.canWrite() || !srcFile.canWrite())
+            if (!dstFile.canWrite() || !srcFile.canWrite()) {
                 throw new MigrationException(R.string.file_migration_failed_not_writable);
+            }
 
-            if (new File(dstFile, MainApp.getDataFolder()).exists())
+            if (new File(dstFile, MainApp.getDataFolder()).exists()) {
                 throw new MigrationException(R.string.file_migration_failed_dir_already_exists);
+            }
 
-            if (dstFile.getFreeSpace() < FileStorageUtils.getFolderSize(new File(srcFile, MainApp.getDataFolder())))
+            if (dstFile.getFreeSpace() < FileStorageUtils.getFolderSize(new File(srcFile, MainApp.getDataFolder()))) {
                 throw new MigrationException(R.string.file_migration_failed_not_enough_space);
+            }
         }
 
-        void copyFiles() throws MigrationException {
+        private void copyFiles() throws MigrationException {
             File srcFile = new File(mStorageSource + File.separator + MainApp.getDataFolder());
             File dstFile = new File(mStorageTarget + File.separator + MainApp.getDataFolder());
 
             copyDirs(srcFile, dstFile);
         }
 
-        void copyDirs(File src, File dst) throws MigrationException {
-            if (!dst.mkdirs())
+        private void copyDirs(File src, File dst) throws MigrationException {
+            if (!dst.mkdirs()) {
                 throw new MigrationException(R.string.file_migration_failed_while_coping);
+            }
 
             for (File f : src.listFiles()) {
-                if (f.isDirectory())
+                if (f.isDirectory()) {
                     copyDirs(f, new File(dst, f.getName()));
-                else if (!FileStorageUtils.copyFile(f, new File(dst, f.getName())))
+                } else if (!FileStorageUtils.copyFile(f, new File(dst, f.getName()))) {
                     throw new MigrationException(R.string.file_migration_failed_while_coping);
+                }
             }
 
         }
 
-        void updateIndex(Context context) throws MigrationException {
+        private void updateIndex(Context context) throws MigrationException {
             FileDataStorageManager manager = new FileDataStorageManager(null, context.getContentResolver());
 
             try {
@@ -399,26 +406,29 @@ public class StorageMigration {
             }
         }
 
-        void cleanup() {
+        private void cleanup() {
             File srcFile = new File(mStorageSource + File.separator + MainApp.getDataFolder());
-            if (!deleteRecursive(srcFile))
+            if (!deleteRecursive(srcFile)) {
                 Log_OC.w(TAG, "Migration cleanup step failed");
+            }
             srcFile.delete();
         }
 
-        boolean deleteRecursive(File f) {
+        private boolean deleteRecursive(File f) {
             boolean res = true;
-            if (f.isDirectory())
-                for (File c : f.listFiles())
+            if (f.isDirectory()) {
+                for (File c : f.listFiles()) {
                     res = deleteRecursive(c) && res;
+                }
+            }
             return f.delete() && res;
         }
 
-        void rollback() {
+        private void rollback() {
             File dstFile = new File(mStorageTarget + File.separator + MainApp.getDataFolder());
-            if (dstFile.exists())
-                if (!dstFile.delete())
-                    Log_OC.w(TAG, "Rollback step failed");
+            if (dstFile.exists() && !dstFile.delete()) {
+                Log_OC.w(TAG, "Rollback step failed");
+            }
         }
     }
 }

+ 8 - 7
src/com/owncloud/android/ui/activity/UploadFilesActivity.java

@@ -30,7 +30,6 @@ import android.os.Bundle;
 import android.os.Environment;
 import android.support.v4.app.DialogFragment;
 import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
 import android.support.v7.app.ActionBar;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -108,8 +107,7 @@ public class UploadFilesActivity extends FileActivity implements
         /// USER INTERFACE
             
         // Drop-down navigation 
-        mDirectories = new CustomArrayAdapter<String>(this,
-                R.layout.support_simple_spinner_dropdown_item);
+        mDirectories = new CustomArrayAdapter<>(this, R.layout.support_simple_spinner_dropdown_item);
         File currDir = mCurrentDir;
         while(currDir != null && currDir.getParentFile() != null) {
             mDirectories.add(currDir.getName());
@@ -120,8 +118,7 @@ public class UploadFilesActivity extends FileActivity implements
         // Inflate and set the layout view
         setContentView(R.layout.upload_files_layout);
 
-        mFileListFragment = (LocalFileListFragment)
-                getSupportFragmentManager().findFragmentById(R.id.local_files_list);
+        mFileListFragment = (LocalFileListFragment) getSupportFragmentManager().findFragmentById(R.id.local_files_list);
         
         
         // Set input controllers
@@ -210,7 +207,7 @@ public class UploadFilesActivity extends FileActivity implements
 
                 AlertDialog.Builder builder = new AlertDialog.Builder(this);
                 builder.setTitle(R.string.actionbar_sort_title)
-                        .setSingleChoiceItems(R.array.actionbar_sortby, sortOrder ,
+                        .setSingleChoiceItems(R.array.menu_items_sort_by_options, sortOrder,
                                 new DialogInterface.OnClickListener() {
                                     public void onClick(DialogInterface dialog, int which) {
                                         switch (which){
@@ -220,6 +217,9 @@ public class UploadFilesActivity extends FileActivity implements
                                             case 1:
                                                 mFileListFragment.sortByDate(false);
                                                 break;
+                                            case 2:
+                                                mFileListFragment.sortBySize(false);
+                                                break;
                                         }
 
                                         dialog.dismiss();
@@ -256,8 +256,9 @@ public class UploadFilesActivity extends FileActivity implements
         // the next operation triggers a new call to this method, but it's necessary to 
         // ensure that the name exposed in the action bar is the current directory when the 
         // user selected it in the navigation list
-        if (itemPosition != 0)
+        if (itemPosition != 0) {
             getSupportActionBar().setSelectedNavigationItem(0);
+        }
         return true;
     }
 

+ 12 - 11
src/com/owncloud/android/ui/adapter/DiskLruImageCache.java

@@ -43,6 +43,7 @@ public class DiskLruImageCache {
     private static final int CACHE_VERSION = 1;
     private static final int VALUE_COUNT = 1;
     private static final int IO_BUFFER_SIZE = 8 * 1024;
+    private static final String CACHE_TEST_DISK = "cache_test_DISK_";
             
     private static final String TAG = DiskLruImageCache.class.getSimpleName();
 
@@ -85,17 +86,17 @@ public class DiskLruImageCache {
                 mDiskCache.flush();
                 editor.commit();
                 if ( BuildConfig.DEBUG ) {
-                   Log_OC.d( "cache_test_DISK_", "image put on disk cache " + validKey );
+                   Log_OC.d( CACHE_TEST_DISK, "image put on disk cache " + validKey );
                 }
             } else {
                 editor.abort();
                 if ( BuildConfig.DEBUG ) {
-                    Log_OC.d( "cache_test_DISK_", "ERROR on: image put on disk cache " + validKey );
+                    Log_OC.d( CACHE_TEST_DISK, "ERROR on: image put on disk cache " + validKey );
                 }
             }   
         } catch (IOException e) {
             if ( BuildConfig.DEBUG ) {
-                Log_OC.d( "cache_test_DISK_", "ERROR on: image put on disk cache " + validKey );
+                Log_OC.d( CACHE_TEST_DISK, "ERROR on: image put on disk cache " + validKey );
             }
             try {
                 if ( editor != null ) {
@@ -125,15 +126,15 @@ public class DiskLruImageCache {
                 bitmap = BitmapFactory.decodeStream( buffIn );              
             }   
         } catch ( IOException e ) {
-            e.printStackTrace();
+            Log_OC.d(TAG, e.getMessage(), e);
         } finally {
-            if ( snapshot != null ) {
+            if (snapshot != null) {
                 snapshot.close();
             }
         }
 
         if ( BuildConfig.DEBUG ) {
-            Log_OC.d("cache_test_DISK_", bitmap == null ? 
+            Log_OC.d(CACHE_TEST_DISK, bitmap == null ?
                     "not found" : "image read from disk " + validKey);
         }
 
@@ -150,9 +151,9 @@ public class DiskLruImageCache {
             snapshot = mDiskCache.get( validKey );
             contained = snapshot != null;
         } catch (IOException e) {
-            e.printStackTrace();
+            Log_OC.d(TAG, e.getMessage(), e);
         } finally {
-            if ( snapshot != null ) {
+            if (snapshot != null) {
                 snapshot.close();
             }
         }
@@ -163,12 +164,12 @@ public class DiskLruImageCache {
 
     public void clearCache() {
         if ( BuildConfig.DEBUG ) {
-            Log_OC.d( "cache_test_DISK_", "disk cache CLEARED");
+            Log_OC.d( CACHE_TEST_DISK, "disk cache CLEARED");
         }
         try {
             mDiskCache.delete();
         } catch ( IOException e ) {
-            e.printStackTrace();
+            Log_OC.d(TAG, e.getMessage(), e);
         }
     }
 
@@ -190,7 +191,7 @@ public class DiskLruImageCache {
             mDiskCache.remove(validKey);
             Log_OC.d(TAG, "removeKey from cache: " + validKey);
         } catch (IOException e) {
-            e.printStackTrace();
+            Log_OC.d(TAG, e.getMessage(), e);
         }
     }
 }

+ 4 - 1
src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java

@@ -58,10 +58,11 @@ import java.util.Comparator;
 import java.util.Observable;
 import java.util.Observer;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 /**
  * This Adapter populates a ListView with following types of uploads: pending,
  * active, completed. Filtering possible.
- *
  */
 public class ExpandableUploadListAdapter extends BaseExpandableListAdapter implements Observer {
 
@@ -116,10 +117,12 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
                 }
             }
 
+            @SuppressFBWarnings("Bx")
             private int compareUploadId(OCUpload upload1, OCUpload upload2) {
                 return Long.valueOf(upload1.getUploadId()).compareTo(upload2.getUploadId());
             }
 
+            @SuppressFBWarnings("Bx")
             private int compareUpdateTime(OCUpload upload1, OCUpload upload2) {
                 return Long.valueOf(upload2.getUploadEndTimestamp()).compareTo(upload1.getUploadEndTimestamp());
             }

+ 9 - 12
src/com/owncloud/android/ui/adapter/FileListListAdapter.java

@@ -112,15 +112,17 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd
 
     @Override
     public Object getItem(int position) {
-        if (mFiles == null || mFiles.size() <= position)
+        if (mFiles == null || mFiles.size() <= position) {
             return null;
+        }
         return mFiles.get(position);
     }
 
     @Override
     public long getItemId(int position) {
-        if (mFiles == null || mFiles.size() <= position)
+        if (mFiles == null || mFiles.size() <= position) {
             return 0;
+        }
         return mFiles.get(position).getFileId();
     }
 
@@ -298,9 +300,7 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd
             if (!file.isFolder()) {
                 if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) && file.getRemoteId() != null) {
                     // Thumbnail in Cache?
-                    Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
-                            String.valueOf(file.getRemoteId())
-                    );
+                    Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(file.getRemoteId());
                     if (thumbnail != null && !file.needsUpdateThumbnail()) {
 
                         if (MimeTypeUtil.isVideo(file)) {
@@ -384,7 +384,7 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd
      */
     public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager
             , boolean onlyOnDevice) {
-        if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {
+        if (updatedStorageManager != null && !updatedStorageManager.equals(mStorageManager)) {
             mStorageManager = updatedStorageManager;
             mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
         }
@@ -394,19 +394,16 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd
             if (mJustFolders) {
                 mFiles = getFolders(mFiles);
             }
-
             if (!mShowHiddenFiles) {
                 mFiles = filterHiddenFiles(mFiles);
             }
+            mFiles = FileStorageUtils.sortOcFolder(mFiles);
+            mFilesAll.addAll(mFiles);
         } else {
             mFiles = null;
+            mFilesAll.clear();
         }
 
-        mFiles = FileStorageUtils.sortOcFolder(mFiles);
-
-        mFilesAll.clear();
-        mFilesAll.addAll(mFiles);
-
         notifyDataSetChanged();
     }
 

+ 6 - 8
src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java

@@ -43,6 +43,7 @@ import com.owncloud.android.utils.MimeTypeUtil;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Vector;
@@ -56,7 +57,6 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
     private static final String TAG = LocalFileListAdapter.class.getSimpleName();
 
     private Context mContext;
-    private File mDirectory;
     private File[] mFiles = null;
     private Vector<File> mFilesAll = new Vector<File>();
 
@@ -87,8 +87,9 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
 
     @Override
     public Object getItem(int position) {
-        if (mFiles == null || mFiles.length <= position)
+        if (mFiles == null || mFiles.length <= position) {
             return null;
+        }
         return mFiles[position];
     }
 
@@ -267,9 +268,8 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
      * Change the adapted directory for a new one
      * @param directory     New file to adapt. Can be NULL, meaning "no content to adapt".
      */
-    public void swapDirectory(File directory) {
-        mDirectory = directory;
-        mFiles = (mDirectory != null ? mDirectory.listFiles() : null);
+    public void swapDirectory(final File directory) {
+        mFiles = (directory != null ? directory.listFiles() : null);
         if (mFiles != null) {
             Arrays.sort(mFiles, new Comparator<File>() {
                 @Override
@@ -298,9 +298,7 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
 
             mFilesAll.clear();
 
-            for (File mFile : mFiles) {
-                mFilesAll.add(mFile);
-            }
+            Collections.addAll(mFilesAll, mFiles);
         }
         notifyDataSetChanged();
     }

+ 2 - 1
src/com/owncloud/android/ui/adapter/UploaderAdapter.java

@@ -63,8 +63,9 @@ public class UploaderAdapter extends SimpleAdapter {
     @Override
     public View getView(int position, View convertView, ViewGroup parent) {
         View vi = convertView;
-        if (convertView == null)
+        if (convertView == null) {
             vi = inflater.inflate(R.layout.uploader_list_item_layout, null);
+        }
 
         HashMap<String, OCFile> data = (HashMap<String, OCFile>) getItem(position);
         OCFile file = data.get("dirname");

+ 1 - 1
src/com/owncloud/android/ui/adapter/X509CertificateViewAdapter.java

@@ -128,7 +128,7 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif
            final int loVal = b & 0x0F;
            hex.append((char) ('0' + (hiVal + (hiVal / 10 * 7))));
            hex.append((char) ('0' + (loVal + (loVal / 10 * 7))));
-           hex.append(":");
+           hex.append(':');
         }
         return digestType + ":" + newLine + hex.toString().replaceFirst("\\:$","") + newLine + newLine;
      }    

+ 3 - 5
src/com/owncloud/android/ui/asynctasks/CopyAndUploadContentUrisTask.java

@@ -88,7 +88,7 @@ public class CopyAndUploadContentUrisTask extends AsyncTask<Object, Void, Result
             account,
             sourceUris,
             remotePaths,
-            new Integer(behaviour),
+            Integer.valueOf(behaviour),
             contentResolver
         };
     }
@@ -193,10 +193,8 @@ public class CopyAndUploadContentUrisTask extends AsyncTask<Object, Void, Result
             // clean
             if (fullTempPath != null) {
                 File f = new File(fullTempPath);
-                if (f.exists()) {
-                    if (!f.delete()) {
-                        Log_OC.e(TAG, "Could not delete temporary file " + fullTempPath);
-                    }
+                if (f.exists() && !f.delete()) {
+                    Log_OC.e(TAG, "Could not delete temporary file " + fullTempPath);
                 }
             }
 

+ 10 - 7
src/com/owncloud/android/ui/dialog/ConfirmationDialogFragment.java

@@ -92,15 +92,15 @@ public class ConfirmationDialogFragment extends DialogFragment {
         int posBtn = getArguments().getInt(ARG_POSITIVE_BTN_RES, -1);
         int neuBtn = getArguments().getInt(ARG_NEUTRAL_BTN_RES, -1);
         int negBtn = getArguments().getInt(ARG_NEGATIVE_BTN_RES, -1);
-        
+
         if (messageArguments == null) {
             messageArguments = new String[]{};
         }
 
         AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.Theme_ownCloud_Dialog)
-            .setIcon(R.drawable.ic_warning)
-            .setIconAttribute(android.R.attr.alertDialogIcon)
-            .setMessage(String.format(getString(messageId), messageArguments));
+                .setIcon(R.drawable.ic_warning)
+                .setIconAttribute(android.R.attr.alertDialogIcon)
+                .setMessage(String.format(getString(messageId), messageArguments));
 
         if (titleId == 0) {
             builder.setTitle(android.R.string.dialog_alert_title);
@@ -108,7 +108,7 @@ public class ConfirmationDialogFragment extends DialogFragment {
             builder.setTitle(titleId);
         }
 
-        if (posBtn != -1)
+        if (posBtn != -1) {
             builder.setPositiveButton(posBtn,
                     new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int whichButton) {
@@ -118,7 +118,8 @@ public class ConfirmationDialogFragment extends DialogFragment {
                             dialog.dismiss();
                         }
                     });
-        if (neuBtn != -1)
+        }
+        if (neuBtn != -1) {
             builder.setNeutralButton(neuBtn,
                     new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int whichButton) {
@@ -128,7 +129,8 @@ public class ConfirmationDialogFragment extends DialogFragment {
                             dialog.dismiss();
                         }
                     });
-        if (negBtn != -1)
+        }
+        if (negBtn != -1) {
             builder.setNegativeButton(negBtn,
                     new DialogInterface.OnClickListener() {
                         @Override
@@ -139,6 +141,7 @@ public class ConfirmationDialogFragment extends DialogFragment {
                             dialog.dismiss();
                         }
                     });
+        }
       return builder.create();
     }
     

+ 6 - 3
src/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java

@@ -69,24 +69,27 @@ public class ConflictsResolveDialog extends DialogFragment {
 
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
-                               if (mListener != null)
+                               if (mListener != null) {
                                    mListener.conflictDecisionMade(Decision.OVERWRITE);
+                               }
                            }
                        })
                    .setNeutralButton(R.string.conflict_keep_both,
                        new DialogInterface.OnClickListener() {
                             @Override
                             public void onClick(DialogInterface dialog, int which) {
-                                if (mListener != null)
+                                if (mListener != null) {
                                     mListener.conflictDecisionMade(Decision.KEEP_BOTH);
+                                }
                             }
                         })
                    .setNegativeButton(R.string.conflict_use_server_version,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
-                               if (mListener != null)
+                               if (mListener != null) {
                                    mListener.conflictDecisionMade(Decision.SERVER);
+                                }
                            }
                    })
                    .create();

+ 3 - 2
src/com/owncloud/android/ui/dialog/CredentialsDialogFragment.java

@@ -148,8 +148,9 @@ public class CredentialsDialogFragment extends DialogFragment
     
     @Override
     public void onDestroyView() {
-      if (getDialog() != null && getRetainInstance())
-        getDialog().setDismissMessage(null);
+      if (getDialog() != null && getRetainInstance()) {
+          getDialog().setDismissMessage(null);
+      }
       super.onDestroyView();
     }
 

+ 2 - 1
src/com/owncloud/android/ui/dialog/LoadingDialog.java

@@ -76,8 +76,9 @@ public class LoadingDialog extends DialogFragment {
 
     @Override
     public void onDestroyView() {
-        if (getDialog() != null && getRetainInstance())
+        if (getDialog() != null && getRetainInstance()) {
             getDialog().setDismissMessage(null);
+        }
         super.onDestroyView();
     }
 }

+ 2 - 1
src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java

@@ -117,8 +117,9 @@ implements ConfirmationDialogFragmentListener {
             for(OCFile file: files) {
                 containsFavorite = file.isFavorite() || containsFavorite;
 
-                if (containsFavorite)
+                if (containsFavorite) {
                     break;
+                }
             }
         }
 

+ 1 - 1
src/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java

@@ -83,7 +83,7 @@ public class RenameFileDialogFragment
         EditText inputText = ((EditText)v.findViewById(R.id.user_input));
         inputText.setText(currentName);
         int selectionStart = 0;
-        int extensionStart = mTargetFile.isFolder() ? -1 : currentName.lastIndexOf(".");
+        int extensionStart = mTargetFile.isFolder() ? -1 : currentName.lastIndexOf('.');
         int selectionEnd = (extensionStart >= 0) ? extensionStart : currentName.length();
         if (selectionStart >= 0 && selectionEnd >= 0) {
             inputText.setSelection(

+ 1 - 5
src/com/owncloud/android/ui/dialog/SamlWebViewDialog.java

@@ -51,8 +51,6 @@ import com.owncloud.android.lib.common.utils.Log_OC;
  */
 public class SamlWebViewDialog extends DialogFragment {
 
-    public final String SAML_DIALOG_TAG = "SamlWebViewDialog";
-    
     private final static String TAG =  SamlWebViewDialog.class.getSimpleName();
 
     private static final String ARG_INITIAL_URL = "INITIAL_URL";
@@ -63,8 +61,6 @@ public class SamlWebViewDialog extends DialogFragment {
     
     private String mInitialUrl;
     private String mTargetUrl;
-    
-    private Handler mHandler;
 
     private SsoWebViewClientListener mSsoWebViewClientListener;
 
@@ -97,7 +93,7 @@ public class SamlWebViewDialog extends DialogFragment {
         super.onAttach(activity);
         try {
             mSsoWebViewClientListener = (SsoWebViewClientListener) activity;
-            mHandler = new Handler();
+            Handler mHandler = new Handler();
             mWebViewClient = new SsoWebViewClient(activity, mHandler, mSsoWebViewClientListener);
             
        } catch (ClassCastException e) {

+ 2 - 1
src/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java

@@ -179,8 +179,9 @@ public class SslUntrustedCertDialog extends DialogFragment {
     @Override
     public void onDestroyView() {
         Log_OC.d(TAG, "onDestroyView");
-        if (getDialog() != null && getRetainInstance())
+        if (getDialog() != null && getRetainInstance()) {
             getDialog().setDismissMessage(null);
+        }
         super.onDestroyView();
     }
     

+ 9 - 14
src/com/owncloud/android/ui/dialog/SslValidatorDialog.java

@@ -71,8 +71,7 @@ public class SslValidatorDialog extends Dialog {
      */
     public static SslValidatorDialog newInstance(Context context, RemoteOperationResult result, OnSslValidatorListener listener) {
         if (result != null && result.isSslRecoverableException()) {
-            SslValidatorDialog dialog = new SslValidatorDialog(context, listener);
-            return dialog;
+            return new SslValidatorDialog(context, listener);
         } else {
             return null;
         }
@@ -109,22 +108,19 @@ public class SslValidatorDialog extends Dialog {
                         try {
                             saveServerCert();
                             dismiss();
-                            if (mListener != null)
+                            if (mListener != null) {
                                 mListener.onSavedCertificate();
-                            else
+                            } else {
                                 Log_OC.d(TAG, "Nobody there to notify the certificate was saved");
+                            }
                             
-                        } catch (GeneralSecurityException e) {
+                        } catch (GeneralSecurityException | IOException e) {
                             dismiss();
-                            if (mListener != null)
+                            if (mListener != null) {
                                 mListener.onFailedSavingCertificate();
+                            }
                             Log_OC.e(TAG, "Server certificate could not be saved in the known servers trust store ", e);
                             
-                        } catch (IOException e) {
-                            dismiss();
-                            if (mListener != null)
-                                mListener.onFailedSavingCertificate();
-                            Log_OC.e(TAG, "Server certificate could not be saved in the known servers trust store ", e);
                         }
                     }
                 });
@@ -145,7 +141,6 @@ public class SslValidatorDialog extends Dialog {
                        if (detailsScroll.getVisibility() == View.VISIBLE) {
                            detailsScroll.setVisibility(View.GONE);
                            ((Button) v).setText(R.string.ssl_validator_btn_details_see);
-                           
                        } else {
                            detailsScroll.setVisibility(View.VISIBLE);
                            ((Button) v).setText(R.string.ssl_validator_btn_details_hide);
@@ -198,8 +193,8 @@ public class SslValidatorDialog extends Dialog {
             showSignature(cert);
             
         } else {
-            // this should not happen
-            // TODO
+            // this should not happen, TODO
+            Log_OC.d("certNull", "This should not happen");
         }
     }
 

+ 28 - 31
src/com/owncloud/android/ui/errorhandling/ExceptionHandler.java

@@ -29,7 +29,6 @@ import android.util.Log;
 
 public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler {
 	private final Activity mContext;
-	private final String LINE_SEPARATOR = "\n";
 
 	private static final String TAG = ExceptionHandler.class.getSimpleName();
 
@@ -41,36 +40,34 @@ public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandl
 	    Log.e(TAG, "ExceptionHandler caught UncaughtException", exception);
 		StringWriter stackTrace = new StringWriter();
 		exception.printStackTrace(new PrintWriter(stackTrace));
-		StringBuilder errorReport = new StringBuilder();
-		errorReport.append("************ CAUSE OF ERROR ************\n\n");
-		errorReport.append(stackTrace.toString());
-
-		errorReport.append("\n************ DEVICE INFORMATION ***********\n");
-		errorReport.append("Brand: ");
-		errorReport.append(Build.BRAND);
-		errorReport.append(LINE_SEPARATOR);
-		errorReport.append("Device: ");
-		errorReport.append(Build.DEVICE);
-		errorReport.append(LINE_SEPARATOR);
-		errorReport.append("Model: ");
-		errorReport.append(Build.MODEL);
-		errorReport.append(LINE_SEPARATOR);
-		errorReport.append("Id: ");
-		errorReport.append(Build.ID);
-		errorReport.append(LINE_SEPARATOR);
-		errorReport.append("Product: ");
-		errorReport.append(Build.PRODUCT);
-		errorReport.append(LINE_SEPARATOR);
-		errorReport.append("\n************ FIRMWARE ************\n");
-		errorReport.append("SDK: ");
-		errorReport.append(Build.VERSION.SDK_INT);
-		errorReport.append(LINE_SEPARATOR);
-		errorReport.append("Release: ");
-		errorReport.append(Build.VERSION.RELEASE);
-		errorReport.append(LINE_SEPARATOR);
-		errorReport.append("Incremental: ");
-		errorReport.append(Build.VERSION.INCREMENTAL);
-		errorReport.append(LINE_SEPARATOR);
+		final StringBuilder errorReport = new StringBuilder(192);
+		final String LINE_SEPARATOR = "\n";
+		errorReport.append("************ CAUSE OF ERROR ************\n\n")
+				.append(stackTrace.toString())
+				.append("\n************ DEVICE INFORMATION ***********\nBrand: ")
+				.append(Build.BRAND)
+				.append(LINE_SEPARATOR)
+				.append("Device: ")
+				.append(Build.DEVICE)
+				.append(LINE_SEPARATOR)
+				.append("Model: ")
+				.append(Build.MODEL)
+				.append(LINE_SEPARATOR)
+				.append("Id: ")
+				.append(Build.ID)
+				.append(LINE_SEPARATOR)
+				.append("Product: ")
+				.append(Build.PRODUCT)
+				.append(LINE_SEPARATOR)
+				.append("\n************ FIRMWARE ************\nSDK: ")
+				.append(Build.VERSION.SDK_INT)
+				.append(LINE_SEPARATOR)
+				.append("Release: ")
+				.append(Build.VERSION.RELEASE)
+				.append(LINE_SEPARATOR)
+				.append("Incremental: ")
+				.append(Build.VERSION.INCREMENTAL)
+				.append(LINE_SEPARATOR);
 
 		Log.e(TAG, "An exception was thrown and handled by ExceptionHandler:", exception);
 

+ 2 - 4
src/com/owncloud/android/ui/fragment/EditShareFragment.java

@@ -64,9 +64,6 @@ public class EditShareFragment extends Fragment {
     /** File bound to mShare, received as a parameter in construction time */
     private OCFile mFile;
 
-    /** OC account holding the shared file, received as a parameter in construction time */
-    private Account mAccount;
-
     /** Listener for changes on privilege checkboxes */
     private CompoundButton.OnCheckedChangeListener mOnPrivilegeChangeListener;
 
@@ -106,7 +103,8 @@ public class EditShareFragment extends Fragment {
         if (getArguments() != null) {
             mShare = getArguments().getParcelable(ARG_SHARE);
             mFile = getArguments().getParcelable(ARG_FILE);
-            mAccount = getArguments().getParcelable(ARG_ACCOUNT);
+            /* OC account holding the shared file, received as a parameter in construction time */
+            //Account mAccount = getArguments().getParcelable(ARG_ACCOUNT);
         }
     }
 

Some files were not shown because too many files changed in this diff