From c5822827b49ede21b9d50de14b53f1541f6e2979 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 27 Nov 2017 14:53:29 +0100 Subject: [PATCH 01/18] revert timeout to 60s --- .../owncloud/android/authentication/AuthenticatorActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java index cefa7ddcff..fd65cbe5ad 100644 --- a/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -461,7 +461,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } }).show(); } - }, 1000); + }, 60000); } private void parseAndLoginFromWebView(String dataString) { From cfef0c9c90cc5be2c2ae723578112a2bc6babb3a Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Sat, 2 Dec 2017 11:38:37 +0100 Subject: [PATCH 02/18] use displayname for sharing, fallback to userid --- .../android/ui/activity/ShareActivity.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java b/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java index 7fa10ef7ad..5c008a6c23 100644 --- a/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java @@ -32,6 +32,7 @@ import android.support.v4.app.FragmentTransaction; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.accounts.AccountUtils; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; @@ -313,7 +314,19 @@ public class ShareActivity extends FileActivity implements ShareFragmentListener intentToShareLink.putExtra(Intent.EXTRA_TEXT, link); intentToShareLink.setType("text/plain"); - String username = AccountUtils.getUsernameForAccount(getAccount()); + + String username; + try { + OwnCloudAccount oca = new OwnCloudAccount(getAccount(), this); + if (oca.getDisplayName() != null && !oca.getDisplayName().isEmpty()) { + username = oca.getDisplayName(); + } else { + username = AccountUtils.getUsernameForAccount(getAccount()); + } + } catch (Exception e) { + username = AccountUtils.getUsernameForAccount(getAccount()); + } + if (username != null) { intentToShareLink.putExtra( Intent.EXTRA_SUBJECT, From c3ff1ccebddc1620da09ea5cd81983f02e4c1cb5 Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Sat, 2 Dec 2017 11:39:13 +0100 Subject: [PATCH 03/18] minor formatting --- .../com/owncloud/android/ui/activity/ShareActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java b/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java index 5c008a6c23..ba2170c449 100644 --- a/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java @@ -1,20 +1,20 @@ -/** +/* * ownCloud Android client application * * @author masensio * @author David A. Velasco * @author Juan Carlos González Cabrero * 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 . */ From 941bb063d922e95b6306cd8cbe92954c992584c5 Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Tue, 5 Dec 2017 14:14:42 +0100 Subject: [PATCH 04/18] bugfix --- .../com/owncloud/android/providers/FileContentProvider.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/owncloud/android/providers/FileContentProvider.java b/src/main/java/com/owncloud/android/providers/FileContentProvider.java index 8abc432766..17c52c0bca 100644 --- a/src/main/java/com/owncloud/android/providers/FileContentProvider.java +++ b/src/main/java/com/owncloud/android/providers/FileContentProvider.java @@ -592,7 +592,8 @@ public class FileContentProvider extends ContentProvider { sqlQuery.setProjectionMap(projectionMap); } - if (selectionArgs == null) { + // if both are null, let them pass to query + if (selectionArgs == null && selection != null) { selectionArgs = new String[]{selection}; selection = "(?)"; } From ce7dbb437f7cdbef28b2ce8024a01e536188722f Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Mon, 11 Dec 2017 01:10:55 +0100 Subject: [PATCH 05/18] CRC32 magic Signed-off-by: Mario Danic --- .../android/datamodel/FileSystemDataSet.java | 14 ++++++- .../datamodel/FilesystemDataProvider.java | 41 ++++++++++++++++++- .../com/owncloud/android/db/ProviderMeta.java | 3 +- .../providers/FileContentProvider.java | 16 ++++++++ 4 files changed, 70 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java b/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java index 59bc0c9c67..35afe1a944 100644 --- a/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java +++ b/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java @@ -20,6 +20,8 @@ */ package com.owncloud.android.datamodel; +import android.support.annotation.Nullable; + /* Model for filesystem data from the database */ @@ -32,12 +34,13 @@ public class FileSystemDataSet { private boolean isSentForUpload; private long foundAt; private long syncedFolderId; + @Nullable private String crc32; public FileSystemDataSet() { } public FileSystemDataSet(int id, String localPath, long modifiedAt, boolean isFolder, - boolean isSentForUpload, long foundAt, long syncedFolderId) { + boolean isSentForUpload, long foundAt, long syncedFolderId, @Nullable String crc32) { this.id = id; this.localPath = localPath; this.modifiedAt = modifiedAt; @@ -45,6 +48,15 @@ public class FileSystemDataSet { this.isSentForUpload = isSentForUpload; this.foundAt = foundAt; this.syncedFolderId = syncedFolderId; + this.crc32 = crc32; + } + + public String getCrc32() { + return crc32; + } + + public void setCrc32(String crc32) { + this.crc32 = crc32; } public int getId() { diff --git a/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java b/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java index 72c6930e17..7937cea0d8 100644 --- a/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java +++ b/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java @@ -27,8 +27,14 @@ import android.net.Uri; import com.owncloud.android.db.ProviderMeta; import com.owncloud.android.lib.common.utils.Log_OC; +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.util.HashSet; import java.util.Set; +import java.util.zip.CRC32; /** * Provider for stored filesystem data. @@ -119,6 +125,11 @@ public class FilesystemDataProvider { cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD, false); cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_SYNCED_FOLDER_ID, syncedFolder.getId()); + long newCrc32 = getFileChecksum(localPath); + if (newCrc32 != -1) { + cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_CRC32, Long.toString(newCrc32)); + } + Uri result = contentResolver.insert(ProviderMeta.ProviderTableMeta.CONTENT_URI_FILESYSTEM, cv); if (result == null) { @@ -127,7 +138,11 @@ public class FilesystemDataProvider { } else { if (data.getModifiedAt() != modifiedAt) { - cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD, 0); + long newCrc32 = getFileChecksum(localPath); + if (data.getCrc32() == null || (newCrc32 != -1 && data.getCrc32().equals(Long.toString(newCrc32)))) { + cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_CRC32, Long.toString(newCrc32)); + cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD, 0); + } } @@ -177,11 +192,13 @@ public class FilesystemDataProvider { isSentForUpload = true; } + String crc32 = cursor.getString(cursor.getColumnIndex(ProviderMeta.ProviderTableMeta.FILESYSTEM_CRC32)); + if (id == -1) { Log_OC.e(TAG, "Arbitrary value could not be created from cursor"); } else { dataSet = new FileSystemDataSet(id, localPath, modifiedAt, isFolder, isSentForUpload, foundAt, - syncedFolder.getId()); + syncedFolder.getId(), crc32); } } cursor.close(); @@ -191,4 +208,24 @@ public class FilesystemDataProvider { return dataSet; } + + private static long getFileChecksum(String filepath) { + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(new FileInputStream(filepath)); + CRC32 crc = new CRC32(); + int cnt; + while ((cnt = inputStream.read()) != -1) { + crc.update(cnt); + } + + return crc.getValue(); + + } catch (FileNotFoundException e) { + return -1; + } catch (IOException e) { + return -1; + } + } } diff --git a/src/main/java/com/owncloud/android/db/ProviderMeta.java b/src/main/java/com/owncloud/android/db/ProviderMeta.java index 13eb79f9e2..9cc3189443 100644 --- a/src/main/java/com/owncloud/android/db/ProviderMeta.java +++ b/src/main/java/com/owncloud/android/db/ProviderMeta.java @@ -32,7 +32,7 @@ import com.owncloud.android.MainApp; public class ProviderMeta { public static final String DB_NAME = "filelist"; - public static final int DB_VERSION = 25; + public static final int DB_VERSION = 26; private ProviderMeta() { } @@ -218,5 +218,6 @@ public class ProviderMeta { public static final String FILESYSTEM_FILE_FOUND_RECENTLY = "found_at"; public static final String FILESYSTEM_FILE_SENT_FOR_UPLOAD = "upload_triggered"; public static final String FILESYSTEM_SYNCED_FOLDER_ID = "syncedfolder_id"; + public static final String FILESYSTEM_CRC32 = "crc32"; } } \ No newline at end of file diff --git a/src/main/java/com/owncloud/android/providers/FileContentProvider.java b/src/main/java/com/owncloud/android/providers/FileContentProvider.java index 8abc432766..895b719144 100644 --- a/src/main/java/com/owncloud/android/providers/FileContentProvider.java +++ b/src/main/java/com/owncloud/android/providers/FileContentProvider.java @@ -1189,6 +1189,21 @@ public class FileContentProvider extends ContentProvider { } } + if (oldVersion < 26 && newVersion >= 26) { + Log_OC.i(SQL, "Entering in the #25 Adding text and element color to capabilities"); + db.beginTransaction(); + try { + db.execSQL(ALTER_TABLE + ProviderTableMeta.FILESYSTEM_TABLE_NAME + + ADD_COLUMN + ProviderTableMeta.FILESYSTEM_CRC32 + " TEXT "); + + upgraded = true; + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + } + + if (!upgraded) { Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion)); } @@ -1380,6 +1395,7 @@ public class FileContentProvider extends ContentProvider { + ProviderTableMeta.FILESYSTEM_FILE_FOUND_RECENTLY + " LONG, " + ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD + " INTEGER, " + ProviderTableMeta.FILESYSTEM_SYNCED_FOLDER_ID + " STRING, " + + ProviderTableMeta.FILESYSTEM_CRC32 + " STRING, " + ProviderTableMeta.FILESYSTEM_FILE_MODIFIED + " LONG );" ); } From 27954c42874dd114447e435eea55298a6de3f9ff Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Mon, 11 Dec 2017 01:31:08 +0100 Subject: [PATCH 06/18] Fix for the fix xD Signed-off-by: Mario Danic --- .../com/owncloud/android/datamodel/FilesystemDataProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java b/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java index 7937cea0d8..f1cf283e9d 100644 --- a/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java +++ b/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java @@ -139,7 +139,7 @@ public class FilesystemDataProvider { if (data.getModifiedAt() != modifiedAt) { long newCrc32 = getFileChecksum(localPath); - if (data.getCrc32() == null || (newCrc32 != -1 && data.getCrc32().equals(Long.toString(newCrc32)))) { + if (data.getCrc32() == null || (newCrc32 != -1 && !data.getCrc32().equals(Long.toString(newCrc32)))) { cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_CRC32, Long.toString(newCrc32)); cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD, 0); } From 96a2dd8e713aa6d06245860a45447aebfebab025 Mon Sep 17 00:00:00 2001 From: AndyScherzinger Date: Mon, 11 Dec 2017 09:29:46 +0100 Subject: [PATCH 07/18] fix log statement --- .../com/owncloud/android/providers/FileContentProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/owncloud/android/providers/FileContentProvider.java b/src/main/java/com/owncloud/android/providers/FileContentProvider.java index 895b719144..af963e9b5a 100644 --- a/src/main/java/com/owncloud/android/providers/FileContentProvider.java +++ b/src/main/java/com/owncloud/android/providers/FileContentProvider.java @@ -1190,7 +1190,7 @@ public class FileContentProvider extends ContentProvider { } if (oldVersion < 26 && newVersion >= 26) { - Log_OC.i(SQL, "Entering in the #25 Adding text and element color to capabilities"); + Log_OC.i(SQL, "Entering in the #26 Adding CRC32 column to filesystem table"); db.beginTransaction(); try { db.execSQL(ALTER_TABLE + ProviderTableMeta.FILESYSTEM_TABLE_NAME + From 4c3b2e65a2279e5e3998a945132d696ff6d522f0 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 11 Dec 2017 15:14:35 +0100 Subject: [PATCH 08/18] always push lint results, either as new master or for PR/master commit --- scripts/lint/lint-up-wrapper.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/lint/lint-up-wrapper.sh b/scripts/lint/lint-up-wrapper.sh index 8b27f7f01b..1f8dc1d179 100755 --- a/scripts/lint/lint-up-wrapper.sh +++ b/scripts/lint/lint-up-wrapper.sh @@ -17,15 +17,20 @@ returnValue=$? echo "Branch: $3" -if [ $3 = "master" -a $returnValue -eq 0 ]; then +if [ $3 = "master" -a $returnValue -ne 1 ]; then echo "New master at: https://nextcloud.kaminsky.me/index.php/s/tXwtChzyqMj6I8v" curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/droneLogs/master.html --upload-file build/reports/lint/lint.html exit 0 -elif [ $returnValue -eq 1 ]; then - if [ -e $6 ] ; then +else + if [ -e $6 ]; then 6="master-"$(date +%F) fi echo "New results at https://nextcloud.kaminsky.me/index.php/s/tXwtChzyqMj6I8v ->" $6.html curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/droneLogs/$6.html --upload-file build/reports/lint/lint.html - exit 1 + + if [ $returnValue -eq 2 ]; then + exit 0 + else + exit 1 + fi fi From 28579d5a0e9c9d99fb8f9d84e2d687fbf1c04284 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 11 Dec 2017 15:42:30 +0100 Subject: [PATCH 09/18] reduce one warning to have an updated master --- src/main/res/values-ast/strings.xml | 1 - src/main/res/values-bg-rBG/strings.xml | 1 - src/main/res/values-ca/strings.xml | 1 - src/main/res/values-cs-rCZ/strings.xml | 1 - src/main/res/values-da/strings.xml | 1 - src/main/res/values-de-rDE/strings.xml | 1 - src/main/res/values-de/strings.xml | 1 - src/main/res/values-el/strings.xml | 1 - src/main/res/values-en-rGB/strings.xml | 1 - src/main/res/values-es-rAR/strings.xml | 1 - src/main/res/values-es-rCL/strings.xml | 1 - src/main/res/values-es-rCO/strings.xml | 1 - src/main/res/values-es-rCR/strings.xml | 1 - src/main/res/values-es-rDO/strings.xml | 1 - src/main/res/values-es-rEC/strings.xml | 1 - src/main/res/values-es-rGT/strings.xml | 1 - src/main/res/values-es-rHN/strings.xml | 1 - src/main/res/values-es-rMX/strings.xml | 1 - src/main/res/values-es-rNI/strings.xml | 1 - src/main/res/values-es-rPA/strings.xml | 1 - src/main/res/values-es-rPE/strings.xml | 1 - src/main/res/values-es-rPR/strings.xml | 1 - src/main/res/values-es-rPY/strings.xml | 1 - src/main/res/values-es-rSV/strings.xml | 1 - src/main/res/values-es-rUY/strings.xml | 1 - src/main/res/values-es/strings.xml | 1 - src/main/res/values-eu/strings.xml | 1 - src/main/res/values-fi-rFI/strings.xml | 1 - src/main/res/values-fr/strings.xml | 1 - src/main/res/values-hu-rHU/strings.xml | 1 - src/main/res/values-id/strings.xml | 1 - src/main/res/values-is/strings.xml | 1 - src/main/res/values-it/strings.xml | 1 - src/main/res/values-ja-rJP/strings.xml | 1 - src/main/res/values-ka-rGE/strings.xml | 1 - src/main/res/values-lt-rLT/strings.xml | 1 - src/main/res/values-nb-rNO/strings.xml | 1 - src/main/res/values-nl/strings.xml | 1 - src/main/res/values-pl/strings.xml | 1 - src/main/res/values-pt-rBR/strings.xml | 1 - src/main/res/values-ro/strings.xml | 1 - src/main/res/values-ru/strings.xml | 1 - src/main/res/values-sk-rSK/strings.xml | 1 - src/main/res/values-sl/strings.xml | 1 - src/main/res/values-sq/strings.xml | 1 - src/main/res/values-sr/strings.xml | 1 - src/main/res/values-sv/strings.xml | 1 - src/main/res/values-tr/strings.xml | 1 - src/main/res/values-zh-rCN/strings.xml | 1 - src/main/res/values-zh-rTW/strings.xml | 1 - src/main/res/values/strings.xml | 1 - 51 files changed, 51 deletions(-) diff --git a/src/main/res/values-ast/strings.xml b/src/main/res/values-ast/strings.xml index bdc5a8fe3d..7d91832d4c 100644 --- a/src/main/res/values-ast/strings.xml +++ b/src/main/res/values-ast/strings.xml @@ -356,7 +356,6 @@ guardáu en carpeta orixinal movíu a la carpeta d\'aplicaciones Camín d\'almacenamientu - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-bg-rBG/strings.xml b/src/main/res/values-bg-rBG/strings.xml index c7e0204dbf..af1861ee55 100644 --- a/src/main/res/values-bg-rBG/strings.xml +++ b/src/main/res/values-bg-rBG/strings.xml @@ -300,7 +300,6 @@ премествани в папката на приложението изтривани Път до хранилището - Познато Споделяне Споделяне на %1$s diff --git a/src/main/res/values-ca/strings.xml b/src/main/res/values-ca/strings.xml index ebc1a8e16d..de40b0bbb4 100644 --- a/src/main/res/values-ca/strings.xml +++ b/src/main/res/values-ca/strings.xml @@ -392,7 +392,6 @@ mogut a la carpeta de l\'aplicació eliminat Ruta d\'emmagatzematge - Comú Compartint Comparteix %1$s diff --git a/src/main/res/values-cs-rCZ/strings.xml b/src/main/res/values-cs-rCZ/strings.xml index 278a8f0b06..4200023391 100644 --- a/src/main/res/values-cs-rCZ/strings.xml +++ b/src/main/res/values-cs-rCZ/strings.xml @@ -467,7 +467,6 @@ přesunut do adresáře aplikace smazáno Cesta k úložišti - Obvyklý Sdílení Sdílet %1$s diff --git a/src/main/res/values-da/strings.xml b/src/main/res/values-da/strings.xml index f97803f513..d978ca73c3 100644 --- a/src/main/res/values-da/strings.xml +++ b/src/main/res/values-da/strings.xml @@ -346,7 +346,6 @@ Vælg alle Slettet - Almindelig Deling Del %1$s diff --git a/src/main/res/values-de-rDE/strings.xml b/src/main/res/values-de-rDE/strings.xml index 5add328066..c0e7279162 100644 --- a/src/main/res/values-de-rDE/strings.xml +++ b/src/main/res/values-de-rDE/strings.xml @@ -470,7 +470,6 @@ in den App-Ordner verschoben gelöscht Speicherort - Allgemein Teilen Teile %1$s diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index 7d5f57ad39..3808fd79a4 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -470,7 +470,6 @@ in den App-Ordner verschoben gelöscht Speicherort - Allgemein Teilen Teile %1$s diff --git a/src/main/res/values-el/strings.xml b/src/main/res/values-el/strings.xml index 0207843de1..d3fa4b4131 100644 --- a/src/main/res/values-el/strings.xml +++ b/src/main/res/values-el/strings.xml @@ -421,7 +421,6 @@ μετακινήθηκε στον φάκελο εφαρμογών διαγράφηκε Διαδρομή αποθηκευτικού χώρου - Κοινό Γίνεται διαμοιρασμός Διαμοιρασμός %1$s diff --git a/src/main/res/values-en-rGB/strings.xml b/src/main/res/values-en-rGB/strings.xml index 55a6d7abf3..49cdc223b4 100644 --- a/src/main/res/values-en-rGB/strings.xml +++ b/src/main/res/values-en-rGB/strings.xml @@ -469,7 +469,6 @@ moved to app folder deleted Storage path - Common Sharing Share %1$s diff --git a/src/main/res/values-es-rAR/strings.xml b/src/main/res/values-es-rAR/strings.xml index 23c24a6b84..385ac731e7 100644 --- a/src/main/res/values-es-rAR/strings.xml +++ b/src/main/res/values-es-rAR/strings.xml @@ -416,7 +416,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rCL/strings.xml b/src/main/res/values-es-rCL/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rCL/strings.xml +++ b/src/main/res/values-es-rCL/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rCO/strings.xml b/src/main/res/values-es-rCO/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rCO/strings.xml +++ b/src/main/res/values-es-rCO/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rCR/strings.xml b/src/main/res/values-es-rCR/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rCR/strings.xml +++ b/src/main/res/values-es-rCR/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rDO/strings.xml b/src/main/res/values-es-rDO/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rDO/strings.xml +++ b/src/main/res/values-es-rDO/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rEC/strings.xml b/src/main/res/values-es-rEC/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rEC/strings.xml +++ b/src/main/res/values-es-rEC/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rGT/strings.xml b/src/main/res/values-es-rGT/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rGT/strings.xml +++ b/src/main/res/values-es-rGT/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rHN/strings.xml b/src/main/res/values-es-rHN/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rHN/strings.xml +++ b/src/main/res/values-es-rHN/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rMX/strings.xml b/src/main/res/values-es-rMX/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rMX/strings.xml +++ b/src/main/res/values-es-rMX/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rNI/strings.xml b/src/main/res/values-es-rNI/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rNI/strings.xml +++ b/src/main/res/values-es-rNI/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rPA/strings.xml b/src/main/res/values-es-rPA/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rPA/strings.xml +++ b/src/main/res/values-es-rPA/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rPE/strings.xml b/src/main/res/values-es-rPE/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rPE/strings.xml +++ b/src/main/res/values-es-rPE/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rPR/strings.xml b/src/main/res/values-es-rPR/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rPR/strings.xml +++ b/src/main/res/values-es-rPR/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rPY/strings.xml b/src/main/res/values-es-rPY/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rPY/strings.xml +++ b/src/main/res/values-es-rPY/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rSV/strings.xml b/src/main/res/values-es-rSV/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rSV/strings.xml +++ b/src/main/res/values-es-rSV/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es-rUY/strings.xml b/src/main/res/values-es-rUY/strings.xml index 26a2cf1387..bec40cd07d 100644 --- a/src/main/res/values-es-rUY/strings.xml +++ b/src/main/res/values-es-rUY/strings.xml @@ -469,7 +469,6 @@ movido a la capreta de la aplicación Borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-es/strings.xml b/src/main/res/values-es/strings.xml index eea9e9037b..d3ee004ac5 100644 --- a/src/main/res/values-es/strings.xml +++ b/src/main/res/values-es/strings.xml @@ -469,7 +469,6 @@ movido a la carpeta de la app borrado Ruta de almacenamiento - Común Compartiendo Compartir %1$s diff --git a/src/main/res/values-eu/strings.xml b/src/main/res/values-eu/strings.xml index be134e3a14..af7deabe0f 100644 --- a/src/main/res/values-eu/strings.xml +++ b/src/main/res/values-eu/strings.xml @@ -363,7 +363,6 @@ Mesedez, baimendu berriz Aplikazioaren karpetara mugitu Borratua Biltegiratze helbidea - Komuna Partekatzea Partekatu %1$s diff --git a/src/main/res/values-fi-rFI/strings.xml b/src/main/res/values-fi-rFI/strings.xml index 01ba6c5cf3..66bd4096cd 100644 --- a/src/main/res/values-fi-rFI/strings.xml +++ b/src/main/res/values-fi-rFI/strings.xml @@ -366,7 +366,6 @@ siirretään sovelluskansioon poistettu Tallennustilan polku - Yleinen Jakaminen Jaa %1$s diff --git a/src/main/res/values-fr/strings.xml b/src/main/res/values-fr/strings.xml index 3b946c3035..d8d431b517 100644 --- a/src/main/res/values-fr/strings.xml +++ b/src/main/res/values-fr/strings.xml @@ -471,7 +471,6 @@ Attention la suppression est irréversible. déplacé vers le dossier de l\'application supprimé Chemin de stockage - Commun Partage Partager %1$s diff --git a/src/main/res/values-hu-rHU/strings.xml b/src/main/res/values-hu-rHU/strings.xml index e923961d2c..9708ccbf22 100644 --- a/src/main/res/values-hu-rHU/strings.xml +++ b/src/main/res/values-hu-rHU/strings.xml @@ -470,7 +470,6 @@ áthelyezve az alkalmazás mappába törölt Tároló útvonal - Általános Megosztás %1$s megosztása diff --git a/src/main/res/values-id/strings.xml b/src/main/res/values-id/strings.xml index a40cccd0b2..a69ecc8468 100644 --- a/src/main/res/values-id/strings.xml +++ b/src/main/res/values-id/strings.xml @@ -417,7 +417,6 @@ Dipindahkan ke folder aplikasi terhapus Jalur penyimpanan - Umum Berbagi Bagikan %1$s diff --git a/src/main/res/values-is/strings.xml b/src/main/res/values-is/strings.xml index af251f15f0..2ea840becb 100644 --- a/src/main/res/values-is/strings.xml +++ b/src/main/res/values-is/strings.xml @@ -463,7 +463,6 @@ Smelltu hér til að fá þér einn frá þjónustuaðila. færð í forritsmöppu eytt Slóð á gagnageymslu - Algengt Deiling Deila %1$s diff --git a/src/main/res/values-it/strings.xml b/src/main/res/values-it/strings.xml index 873d637195..6a9992fe1c 100644 --- a/src/main/res/values-it/strings.xml +++ b/src/main/res/values-it/strings.xml @@ -469,7 +469,6 @@ spostato nella cartella dell\'applicazione eliminato Percorso di archiviazione - Comune Condivisione Condividi %1$s diff --git a/src/main/res/values-ja-rJP/strings.xml b/src/main/res/values-ja-rJP/strings.xml index 120d21c27a..9e2508a6a3 100644 --- a/src/main/res/values-ja-rJP/strings.xml +++ b/src/main/res/values-ja-rJP/strings.xml @@ -334,7 +334,6 @@ アプリフォルダに移動 削除されました ストレージの場所 - 共通の 共有 %1$s を共有 diff --git a/src/main/res/values-ka-rGE/strings.xml b/src/main/res/values-ka-rGE/strings.xml index 0f0980a8d7..3a1abe78c8 100644 --- a/src/main/res/values-ka-rGE/strings.xml +++ b/src/main/res/values-ka-rGE/strings.xml @@ -465,7 +465,6 @@ გადატანილია აპლიკაციის დირექტორიაში გაუქმებულია საცავის მისამართი - ჩვეული გაზიარება %1$s-ის გაზიარება diff --git a/src/main/res/values-lt-rLT/strings.xml b/src/main/res/values-lt-rLT/strings.xml index 35fad5237a..7d3fe99e88 100644 --- a/src/main/res/values-lt-rLT/strings.xml +++ b/src/main/res/values-lt-rLT/strings.xml @@ -429,7 +429,6 @@ perkelti į app aplanką Ištrintas Saugojimo kelias - Bendras pavadinimas: Dalijimasis Dalintis %1$s diff --git a/src/main/res/values-nb-rNO/strings.xml b/src/main/res/values-nb-rNO/strings.xml index d9abe48bde..242be18b66 100644 --- a/src/main/res/values-nb-rNO/strings.xml +++ b/src/main/res/values-nb-rNO/strings.xml @@ -469,7 +469,6 @@ flyttet til program-mappe slettet Lagrings-sti - Felles Deling Del %1$s diff --git a/src/main/res/values-nl/strings.xml b/src/main/res/values-nl/strings.xml index e2a002ed41..d9c92cd6e2 100644 --- a/src/main/res/values-nl/strings.xml +++ b/src/main/res/values-nl/strings.xml @@ -470,7 +470,6 @@ Kies er eentje van een provider. verplaatst worden naar app-map verwijderd worden Opslagpad - Gemeenschappelijk Delen Deel %1$s diff --git a/src/main/res/values-pl/strings.xml b/src/main/res/values-pl/strings.xml index 25d851619c..3c767e189c 100644 --- a/src/main/res/values-pl/strings.xml +++ b/src/main/res/values-pl/strings.xml @@ -453,7 +453,6 @@ przeniesiony do folderu aplikacji usunięty Ścieżka przechowywania - Wspólny Udostępnianie Współdziel %1$s diff --git a/src/main/res/values-pt-rBR/strings.xml b/src/main/res/values-pt-rBR/strings.xml index ecbf32fd01..7a19b3ddaa 100644 --- a/src/main/res/values-pt-rBR/strings.xml +++ b/src/main/res/values-pt-rBR/strings.xml @@ -469,7 +469,6 @@ movido para a pasta aplicativos excluído Caminho do armazenamento - Comum Compartilhamento Compartilhar %1$s diff --git a/src/main/res/values-ro/strings.xml b/src/main/res/values-ro/strings.xml index e09e5bb17d..2191991569 100644 --- a/src/main/res/values-ro/strings.xml +++ b/src/main/res/values-ro/strings.xml @@ -294,7 +294,6 @@ mutate în dosarul aplicației șterge Calea către spațiul de depozitare - General Partajare Partajare %1$s diff --git a/src/main/res/values-ru/strings.xml b/src/main/res/values-ru/strings.xml index cf39b8c27a..37548c216a 100644 --- a/src/main/res/values-ru/strings.xml +++ b/src/main/res/values-ru/strings.xml @@ -477,7 +477,6 @@ перемещен в каталог приложения удалён Путь к хранилищу - Основные Общий доступ Общий ресурс «%1$s» diff --git a/src/main/res/values-sk-rSK/strings.xml b/src/main/res/values-sk-rSK/strings.xml index 257f61e04d..6aace0ed10 100644 --- a/src/main/res/values-sk-rSK/strings.xml +++ b/src/main/res/values-sk-rSK/strings.xml @@ -347,7 +347,6 @@ presunuté do aplikačného priečinka vymazané Cesta úložiska - Bežný Sprístupnenie Sprístupni %1$s diff --git a/src/main/res/values-sl/strings.xml b/src/main/res/values-sl/strings.xml index f21d3877ef..16df0b9581 100644 --- a/src/main/res/values-sl/strings.xml +++ b/src/main/res/values-sl/strings.xml @@ -416,7 +416,6 @@ premakni v mapo programa pobrisano Mesto shrambe - Splošno Souporaba Omogoči souporabo %1$s diff --git a/src/main/res/values-sq/strings.xml b/src/main/res/values-sq/strings.xml index d4e06c4d58..6ff3042f3d 100644 --- a/src/main/res/values-sq/strings.xml +++ b/src/main/res/values-sq/strings.xml @@ -444,7 +444,6 @@ u kalua te dosja e aplikacionit të fshira Rruga e hapsirës ruajtëse - E përbashkët Ndarje me të tjerët Ndajeni %1$s diff --git a/src/main/res/values-sr/strings.xml b/src/main/res/values-sr/strings.xml index 91573774ab..27c777c386 100644 --- a/src/main/res/values-sr/strings.xml +++ b/src/main/res/values-sr/strings.xml @@ -473,7 +473,6 @@ премештен у фасциклу апликације обрисано Путања до складишта - Опште Дељење Подели %1$s diff --git a/src/main/res/values-sv/strings.xml b/src/main/res/values-sv/strings.xml index 039ef501ee..768383a7df 100644 --- a/src/main/res/values-sv/strings.xml +++ b/src/main/res/values-sv/strings.xml @@ -421,7 +421,6 @@ flyttas till Nextcloud-mapp raderas Lagringsplats - Vanlig Dela Dela %1$s diff --git a/src/main/res/values-tr/strings.xml b/src/main/res/values-tr/strings.xml index dbeb3bb26c..410108dfc3 100644 --- a/src/main/res/values-tr/strings.xml +++ b/src/main/res/values-tr/strings.xml @@ -469,7 +469,6 @@ app klasörüne taşındı silindi Depolama yolu - Genel Paylaşım %1$s paylaş diff --git a/src/main/res/values-zh-rCN/strings.xml b/src/main/res/values-zh-rCN/strings.xml index 5d424c809e..e8503758cd 100644 --- a/src/main/res/values-zh-rCN/strings.xml +++ b/src/main/res/values-zh-rCN/strings.xml @@ -437,7 +437,6 @@ 移动到应用文件夹 删除 存储路径 - 普通 共享 分享 %1$s diff --git a/src/main/res/values-zh-rTW/strings.xml b/src/main/res/values-zh-rTW/strings.xml index 5a0feb03a3..7b8e63d344 100644 --- a/src/main/res/values-zh-rTW/strings.xml +++ b/src/main/res/values-zh-rTW/strings.xml @@ -446,7 +446,6 @@ 移動到應用程式資料夾 已刪除 儲存路徑 - 共用 分享 分享 %1$s diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 1b4384f0d2..5434ab612c 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -471,7 +471,6 @@ moved to app folder deleted Storage path - Common Sharing Share %1$s From c6e0b0e7b2a77cd3ee83bf6d7fc91c98a83c8c46 Mon Sep 17 00:00:00 2001 From: nextcloud-android-bot <> Date: Mon, 11 Dec 2017 15:01:05 +0000 Subject: [PATCH 10/18] Drone: update Lint results to reflect reduced error/warning count [skip ci] --- scripts/lint/lint-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lint/lint-results.txt b/scripts/lint/lint-results.txt index 169ba1d41e..24e80b6da4 100644 --- a/scripts/lint/lint-results.txt +++ b/scripts/lint/lint-results.txt @@ -1,2 +1,2 @@ DO NOT TOUCH; GENERATED BY DRONE - Lint Report: 335 warnings + Lint Report: 334 warnings From f9628a5f266034753b231f62380ec3355fddba02 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 11 Dec 2017 16:08:37 +0100 Subject: [PATCH 11/18] only rewrite error code 2 -> 0 --- scripts/lint/lint-up-wrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lint/lint-up-wrapper.sh b/scripts/lint/lint-up-wrapper.sh index 1f8dc1d179..cbf8c3f85c 100755 --- a/scripts/lint/lint-up-wrapper.sh +++ b/scripts/lint/lint-up-wrapper.sh @@ -31,6 +31,6 @@ else if [ $returnValue -eq 2 ]; then exit 0 else - exit 1 + exit $returnValue fi fi From 3fab8fa913c96310f7a32439fb1aeac83f43067b Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Mon, 4 Dec 2017 09:59:24 +0100 Subject: [PATCH 12/18] change changelog for dev version to master commits as we do not have any special changelog anylonger --- src/versionDev/res/values/setup.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/versionDev/res/values/setup.xml b/src/versionDev/res/values/setup.xml index e410f0691e..a5a68b78c2 100644 --- a/src/versionDev/res/values/setup.xml +++ b/src/versionDev/res/values/setup.xml @@ -16,6 +16,7 @@ Nextcloud dev true + https://github.com/nextcloud/android/commits/master android@nextcloud.com From e7ad1ddb4b37a547edcf415a59f8b086c123ca4f Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Thu, 30 Nov 2017 09:04:18 +0100 Subject: [PATCH 13/18] further hardening of Content Provider --- .../providers/FileContentProvider.java | 121 ++++++++++++------ 1 file changed, 83 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/owncloud/android/providers/FileContentProvider.java b/src/main/java/com/owncloud/android/providers/FileContentProvider.java index c85c6631b8..ba8bf79df2 100644 --- a/src/main/java/com/owncloud/android/providers/FileContentProvider.java +++ b/src/main/java/com/owncloud/android/providers/FileContentProvider.java @@ -38,6 +38,9 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; +import android.os.Binder; +import android.os.Build; +import android.support.annotation.NonNull; import android.text.TextUtils; import com.owncloud.android.MainApp; @@ -63,6 +66,7 @@ import java.util.Locale; public class FileContentProvider extends ContentProvider { private DataBaseHelper mDbHelper; + private Context mContext; private static final int SINGLE_FILE = 1; private static final int DIRECTORY = 2; @@ -89,9 +93,13 @@ public class FileContentProvider extends ContentProvider { 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) { - //Log_OC.d(TAG, "Deleting " + uri + " at provider " + this); - int count = 0; + public int delete(@NonNull Uri uri, String where, String[] whereArgs) { + int count; + + if (isCallerNotAllowed()) { + return -1; + } + SQLiteDatabase db = mDbHelper.getWritableDatabase(); db.beginTransaction(); try { @@ -100,11 +108,15 @@ public class FileContentProvider extends ContentProvider { } finally { db.endTransaction(); } - getContext().getContentResolver().notifyChange(uri, null); + mContext.getContentResolver().notifyChange(uri, null); return count; } private int delete(SQLiteDatabase db, Uri uri, String where, String[] whereArgs) { + if (isCallerNotAllowed()) { + return -1; + } + int count = 0; switch (mUriMatcher.match(uri)) { case SINGLE_FILE: @@ -221,7 +233,7 @@ public class FileContentProvider extends ContentProvider { } @Override - public String getType(Uri uri) { + public String getType(@NonNull Uri uri) { switch (mUriMatcher.match(uri)) { case ROOT_DIRECTORY: return ProviderTableMeta.CONTENT_TYPE; @@ -234,8 +246,12 @@ public class FileContentProvider extends ContentProvider { } @Override - public Uri insert(Uri uri, ContentValues values) { - Uri newUri = null; + public Uri insert(@NonNull Uri uri, ContentValues values) { + if (isCallerNotAllowed()) { + return null; + } + + Uri newUri; SQLiteDatabase db = mDbHelper.getWritableDatabase(); db.beginTransaction(); try { @@ -244,7 +260,7 @@ public class FileContentProvider extends ContentProvider { } finally { db.endTransaction(); } - getContext().getContentResolver().notifyChange(newUri, null); + mContext.getContentResolver().notifyChange(newUri, null); return newUri; } @@ -286,7 +302,7 @@ public class FileContentProvider extends ContentProvider { } case SHARES: - Uri insertedShareUri = null; + Uri insertedShareUri; long rowId = db.insert(ProviderTableMeta.OCSHARES_TABLE_NAME, null, values); if (rowId > 0) { insertedShareUri = @@ -299,7 +315,7 @@ public class FileContentProvider extends ContentProvider { return insertedShareUri; case CAPABILITIES: - Uri insertedCapUri = null; + Uri insertedCapUri; long id = db.insert(ProviderTableMeta.CAPABILITIES_TABLE_NAME, null, values); if (id > 0) { insertedCapUri = @@ -311,7 +327,7 @@ public class FileContentProvider extends ContentProvider { return insertedCapUri; case UPLOADS: - Uri insertedUploadUri = null; + Uri insertedUploadUri; long uploadId = db.insert(ProviderTableMeta.UPLOADS_TABLE_NAME, null, values); if (uploadId > 0) { insertedUploadUri = @@ -323,7 +339,7 @@ public class FileContentProvider extends ContentProvider { return insertedUploadUri; case SYNCED_FOLDERS: - Uri insertedSyncedFolderUri = null; + Uri insertedSyncedFolderUri; long syncedFolderId = db.insert(ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME, null, values); if (syncedFolderId > 0) { insertedSyncedFolderUri = @@ -335,7 +351,7 @@ public class FileContentProvider extends ContentProvider { return insertedSyncedFolderUri; case EXTERNAL_LINKS: - Uri insertedExternalLinkUri = null; + Uri insertedExternalLinkUri; long externalLinkId = db.insert(ProviderTableMeta.EXTERNAL_LINKS_TABLE_NAME, null, values); if (externalLinkId > 0) { insertedExternalLinkUri = @@ -347,7 +363,7 @@ public class FileContentProvider extends ContentProvider { return insertedExternalLinkUri; case ARBITRARY_DATA: - Uri insertedArbitraryDataUri = null; + Uri insertedArbitraryDataUri; long arbitraryDataId = db.insert(ProviderTableMeta.ARBITRARY_DATA_TABLE_NAME, null, values); if (arbitraryDataId > 0) { insertedArbitraryDataUri = @@ -369,11 +385,11 @@ public class FileContentProvider extends ContentProvider { return insertedVirtualUri; case FILESYSTEM: - Uri insertedFilesystemUri = null; - long filesystedId = db.insert(ProviderTableMeta.FILESYSTEM_TABLE_NAME, null, values); - if (filesystedId > 0) { + Uri insertedFilesystemUri; + long filesystemId = db.insert(ProviderTableMeta.FILESYSTEM_TABLE_NAME, null, values); + if (filesystemId > 0) { insertedFilesystemUri = - ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILESYSTEM, filesystedId); + ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILESYSTEM, filesystemId); } else { throw new SQLException("ERROR " + uri); } @@ -412,8 +428,13 @@ public class FileContentProvider extends ContentProvider { @Override public boolean onCreate() { mDbHelper = new DataBaseHelper(getContext()); + mContext = getContext(); - String authority = getContext().getResources().getString(R.string.authority); + if (mContext == null) { + return false; + } + + String authority = mContext.getResources().getString(R.string.authority); mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); mUriMatcher.addURI(authority, null, ROOT_DIRECTORY); mUriMatcher.addURI(authority, "file/", SINGLE_FILE); @@ -437,15 +458,24 @@ public class FileContentProvider extends ContentProvider { @Override - public Cursor query( - Uri uri, - String[] projection, - String selection, - String[] selectionArgs, - String sortOrder - ) { + public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, + String sortOrder) { - Cursor result = null; + // skip check for files as they need to be queried to get access via document provider + switch (mUriMatcher.match(uri)) { + case ROOT_DIRECTORY: + case SINGLE_FILE: + case DIRECTORY: + break; + + default: + if (isCallerNotAllowed()) { + return null; + } + } + + + Cursor result; SQLiteDatabase db = mDbHelper.getReadableDatabase(); db.beginTransaction(); try { @@ -600,14 +630,18 @@ public class FileContentProvider extends ContentProvider { sqlQuery.setStrict(true); Cursor c = sqlQuery.query(db, projectionArray, selection, selectionArgs, null, null, order); - c.setNotificationUri(getContext().getContentResolver(), uri); + c.setNotificationUri(mContext.getContentResolver(), uri); return c; } @Override - public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { + public int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) { - int count = 0; + if (isCallerNotAllowed()) { + return -1; + } + + int count; SQLiteDatabase db = mDbHelper.getWritableDatabase(); db.beginTransaction(); try { @@ -616,7 +650,7 @@ public class FileContentProvider extends ContentProvider { } finally { db.endTransaction(); } - getContext().getContentResolver().notifyChange(uri, null); + mContext.getContentResolver().notifyChange(uri, null); return count; } @@ -636,8 +670,7 @@ public class FileContentProvider extends ContentProvider { case CAPABILITIES: return db.update(ProviderTableMeta.CAPABILITIES_TABLE_NAME, values, selection, selectionArgs); case UPLOADS: - int ret = db.update(ProviderTableMeta.UPLOADS_TABLE_NAME, values, selection, selectionArgs); - return ret; + return db.update(ProviderTableMeta.UPLOADS_TABLE_NAME, values, selection, selectionArgs); case SYNCED_FOLDERS: return db.update(ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME, values, selection, selectionArgs); case ARBITRARY_DATA: @@ -649,8 +682,9 @@ public class FileContentProvider extends ContentProvider { } } + @NonNull @Override - public ContentProviderResult[] applyBatch(ArrayList operations) + public ContentProviderResult[] applyBatch(@NonNull ArrayList operations) throws OperationApplicationException { Log_OC.d("FileContentProvider", "applying batch in provider " + this + " (temporary: " + isTemporary() + ")"); @@ -675,7 +709,7 @@ public class FileContentProvider extends ContentProvider { class DataBaseHelper extends SQLiteOpenHelper { - public DataBaseHelper(Context context) { + DataBaseHelper(Context context) { super(context, ProviderMeta.DB_NAME, null, ProviderMeta.DB_VERSION); } @@ -686,7 +720,7 @@ public class FileContentProvider extends ContentProvider { Log_OC.i(SQL, "Entering in onCreate"); createFilesTable(db); - // Create ocshares table + // Create OCShares table createOCSharesTable(db); // Create capabilities table @@ -797,7 +831,7 @@ public class FileContentProvider extends ContentProvider { ADD_COLUMN + ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT " + " DEFAULT NULL"); - // Create table ocshares + // Create table OCShares createOCSharesTable(db); upgraded = true; @@ -1259,7 +1293,7 @@ public class FileContentProvider extends ContentProvider { } private void createOCSharesTable(SQLiteDatabase db) { - // Create ocshares table + // Create OCShares table db.execSQL("CREATE TABLE " + ProviderTableMeta.OCSHARES_TABLE_NAME + "(" + ProviderTableMeta._ID + " INTEGER PRIMARY KEY, " + ProviderTableMeta.OCSHARES_FILE_SOURCE + INTEGER @@ -1516,4 +1550,15 @@ public class FileContentProvider extends ContentProvider { c.close(); } } + + private boolean isCallerNotAllowed() { + String callingPackage; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + callingPackage = getCallingPackage(); + } else { + callingPackage = mContext.getPackageManager().getNameForUid(Binder.getCallingUid()); + } + + return callingPackage == null || !callingPackage.contains(mContext.getPackageName()); + } } From acdd470c95ed07d5f42829530049e34476f5c600 Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Mon, 4 Dec 2017 14:43:58 +0100 Subject: [PATCH 14/18] proper handling when switching to an account with disabled external links --- .../android/ui/activity/DrawerActivity.java | 75 +++++++++---------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index da7664ba1f..881e3af52b 100644 --- a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -1335,53 +1335,50 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU */ public void fetchExternalLinks(final boolean force) { if (getBaseContext().getResources().getBoolean(R.bool.show_external_links)) { - Thread t = new Thread(new Runnable() { - public void run() { - // fetch capabilities as early as possible - if ((getCapabilities() == null || getCapabilities().getAccountName().isEmpty()) - && getStorageManager() != null) { - GetCapabilitiesOperarion getCapabilities = new GetCapabilitiesOperarion(); - getCapabilities.execute(getStorageManager(), getBaseContext()); - } + Thread t = new Thread(() -> { + // fetch capabilities as early as possible + if ((getCapabilities() == null || getCapabilities().getAccountName().isEmpty()) + && getStorageManager() != null) { + GetCapabilitiesOperarion getCapabilities = new GetCapabilitiesOperarion(); + getCapabilities.execute(getStorageManager(), getBaseContext()); + } - Account account = AccountUtils.getCurrentOwnCloudAccount(DrawerActivity.this); + Account account = AccountUtils.getCurrentOwnCloudAccount(DrawerActivity.this); - if (account != null && getStorageManager() != null && - getStorageManager().getCapability(account.name) != null && - getStorageManager().getCapability(account.name).getExternalLinks().isTrue()) { + externalLinksProvider.deleteAllExternalLinks(); - int count = sharedPreferences.getInt(EXTERNAL_LINKS_COUNT, -1); - if (count > 10 || count == -1 || force) { - if (force) { - Log_OC.d("ExternalLinks", "force update"); + if (account != null && getStorageManager() != null && + getStorageManager().getCapability(account.name) != null && + getStorageManager().getCapability(account.name).getExternalLinks().isTrue()) { + + int count = sharedPreferences.getInt(EXTERNAL_LINKS_COUNT, -1); + if (count > 10 || count == -1 || force) { + if (force) { + Log_OC.d("ExternalLinks", "force update"); + } + + sharedPreferences.edit().putInt(EXTERNAL_LINKS_COUNT, 0).apply(); + + Log_OC.d("ExternalLinks", "update via api"); + RemoteOperation getExternalLinksOperation = new ExternalLinksOperation(); + RemoteOperationResult result = getExternalLinksOperation.execute(account, DrawerActivity.this); + + if (result.isSuccess() && result.getData() != null) { + externalLinksProvider.deleteAllExternalLinks(); + + ArrayList externalLinks = (ArrayList) (Object) result.getData(); + + for (ExternalLink link : externalLinks) { + externalLinksProvider.storeExternalLink(link); } - - sharedPreferences.edit().putInt(EXTERNAL_LINKS_COUNT, 0).apply(); - - Log_OC.d("ExternalLinks", "update via api"); - ExternalLinksProvider externalLinksProvider = new ExternalLinksProvider(getContentResolver()); - - RemoteOperation getExternalLinksOperation = new ExternalLinksOperation(); - RemoteOperationResult result = getExternalLinksOperation.execute(account, DrawerActivity.this); - - if (result.isSuccess() && result.getData() != null) { - externalLinksProvider.deleteAllExternalLinks(); - - ArrayList externalLinks = (ArrayList) (Object) result.getData(); - - for (ExternalLink link : externalLinks) { - externalLinksProvider.storeExternalLink(link); - } - - runOnUiThread(() -> updateExternalLinksInDrawer()); - } - } else { - sharedPreferences.edit().putInt(EXTERNAL_LINKS_COUNT, count + 1).apply(); } } else { - Log_OC.d("ExternalLinks", "links disabled"); + sharedPreferences.edit().putInt(EXTERNAL_LINKS_COUNT, count + 1).apply(); } + } else { + Log_OC.d("ExternalLinks", "links disabled"); } + runOnUiThread(() -> updateExternalLinksInDrawer()); }); t.start(); From e93eb51ffe47a806c25cfe8623a5d5097bbc5d80 Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Fri, 1 Dec 2017 16:00:09 +0100 Subject: [PATCH 15/18] "set picture as" with resized images --- .../ui/fragment/OCFileListFragment.java | 7 +--- .../ui/helpers/FileOperationsHelper.java | 35 +++++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 26e876f0ae..4181357347 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -985,12 +985,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi } } case R.id.action_set_as_wallpaper: { - if (singleFile.isDown()) { - mContainerActivity.getFileOperationsHelper().setPictureAs(singleFile); - } else { - Log_OC.d(TAG, singleFile.getRemotePath() + " : File must be downloaded"); - ((FileDisplayActivity) mContainerActivity).startDownloadForSending(singleFile, DOWNLOAD_SET_AS); - } + mContainerActivity.getFileOperationsHelper().setPictureAs(singleFile); return true; } } diff --git a/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java index 9cf2e0ec1a..b89a77362e 100755 --- a/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java +++ b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java @@ -56,6 +56,7 @@ import com.owncloud.android.ui.events.FavoriteEvent; import com.owncloud.android.ui.events.SyncEventFinished; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.FileStorageUtils; +import com.owncloud.android.utils.UriUtils; import org.greenrobot.eventbus.EventBus; @@ -582,30 +583,34 @@ public class FileOperationsHelper { public void setPictureAs(OCFile file) { if (file != null) { - if (file.isDown()) { - Context context = MainApp.getAppContext(); + Context context = MainApp.getAppContext(); + Intent intent = new Intent(Intent.ACTION_ATTACH_DATA); + Uri uri; - try { + try { + if (file.isDown()) { File externalFile = new File(file.getStoragePath()); - Intent intent = new Intent(Intent.ACTION_ATTACH_DATA); - Uri sendUri; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - sendUri = FileProvider.getUriForFile(context, + uri = FileProvider.getUriForFile(context, context.getResources().getString(R.string.file_provider_authority), externalFile); } else { - sendUri = Uri.fromFile(externalFile); + uri = Uri.fromFile(externalFile); } - - intent.setDataAndType(sendUri, file.getMimetype()); - intent.putExtra("mimeType", file.getMimetype()); - mFileActivity.startActivityForResult(Intent.createChooser(intent, - mFileActivity.getString(R.string.set_as)), 200); - - } catch (ActivityNotFoundException exception) { - Toast.makeText(context, R.string.picture_set_as_no_app, Toast.LENGTH_LONG).show(); + } else { + uri = Uri.parse(UriUtils.URI_CONTENT_SCHEME + + context.getResources().getString(R.string.image_cache_provider_authority) + + file.getRemotePath()); } + + intent.setDataAndType(uri, file.getMimetype()); + mFileActivity.startActivityForResult(Intent.createChooser(intent, + mFileActivity.getString(R.string.set_as)), 200); + + intent.setDataAndType(uri, file.getMimetype()); + } catch (ActivityNotFoundException exception) { + Toast.makeText(context, R.string.picture_set_as_no_app, Toast.LENGTH_LONG).show(); } } else { Log_OC.wtf(TAG, "Trying to send a NULL OCFile"); From 297c6024bce963a187eb4b6b81c41aed9652be79 Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Mon, 4 Dec 2017 10:50:38 +0100 Subject: [PATCH 16/18] - replace Toast with Snackbar - remove not used code --- .../android/ui/activity/FileDisplayActivity.java | 13 ++----------- .../android/ui/fragment/OCFileListFragment.java | 3 +-- .../android/ui/helpers/FileOperationsHelper.java | 7 ++++--- .../android/ui/preview/PreviewImageFragment.java | 2 +- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 24ef443f93..98fedb13e8 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -1449,9 +1449,6 @@ public class FileDisplayActivity extends HookActivity case OCFileListFragment.DOWNLOAD_SEND: sendDownloadedFile(); break; - case OCFileListFragment.DOWNLOAD_SET_AS: - setPictureAs(); - break; default: // do nothing break; @@ -1609,7 +1606,7 @@ public class FileDisplayActivity extends HookActivity mUploaderBinder = null; } } - }; + } private MediaServiceConnection newMediaConnection(){ return new MediaServiceConnection(); @@ -1639,7 +1636,7 @@ public class FileDisplayActivity extends HookActivity mMediaServiceBinder = null; } } - }; + } /** * Updates the view associated to the activity after the finish of some operation over files @@ -1986,12 +1983,6 @@ public class FileDisplayActivity extends HookActivity mWaitingToSend = null; } - private void setPictureAs() { - getFileOperationsHelper().setPictureAs(mWaitingToSend); - mWaitingToSend = null; - } - - /** * Requests the download of the received {@link OCFile} , updates the UI * to monitor the download progress and prepares the activity to send the file diff --git a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 4181357347..a725efed23 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -129,7 +129,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi public static final String DOWNLOAD_BEHAVIOUR = "DOWNLOAD_BEHAVIOUR"; public static final String DOWNLOAD_SEND = "DOWNLOAD_SEND"; - public static final String DOWNLOAD_SET_AS = "DOWNLOAD_SET_AS"; public static final String SEARCH_EVENT = "SEARCH_EVENT"; @@ -985,7 +984,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi } } case R.id.action_set_as_wallpaper: { - mContainerActivity.getFileOperationsHelper().setPictureAs(singleFile); + mContainerActivity.getFileOperationsHelper().setPictureAs(singleFile, getView()); return true; } } diff --git a/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java index b89a77362e..16e14af627 100755 --- a/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java +++ b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java @@ -30,9 +30,10 @@ import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Build; import android.support.annotation.Nullable; +import android.support.design.widget.Snackbar; import android.support.v4.content.FileProvider; +import android.view.View; import android.webkit.MimeTypeMap; -import android.widget.Toast; import com.owncloud.android.MainApp; import com.owncloud.android.R; @@ -581,7 +582,7 @@ public class FileOperationsHelper { } } - public void setPictureAs(OCFile file) { + public void setPictureAs(OCFile file, View view) { if (file != null) { Context context = MainApp.getAppContext(); Intent intent = new Intent(Intent.ACTION_ATTACH_DATA); @@ -610,7 +611,7 @@ public class FileOperationsHelper { intent.setDataAndType(uri, file.getMimetype()); } catch (ActivityNotFoundException exception) { - Toast.makeText(context, R.string.picture_set_as_no_app, Toast.LENGTH_LONG).show(); + Snackbar.make(view, R.string.picture_set_as_no_app, Snackbar.LENGTH_LONG).show(); } } else { Log_OC.wtf(TAG, "Trying to send a NULL OCFile"); diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java index 42d0cfb3fc..b1f789e54e 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -452,7 +452,7 @@ public class PreviewImageFragment extends FileFragment { return true; case R.id.action_set_as_wallpaper: - mContainerActivity.getFileOperationsHelper().setPictureAs(getFile()); + mContainerActivity.getFileOperationsHelper().setPictureAs(getFile(), getImageView()); return true; default: From aed532d4084d0bef4da44682897dff6b166d2241 Mon Sep 17 00:00:00 2001 From: tobiaskaminsky Date: Mon, 4 Dec 2017 13:19:23 +0100 Subject: [PATCH 17/18] get rid of gallery API and use internal one --- .../android/datamodel/ThumbnailsCacheManager.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index f7ffc0c5bb..df398fd8df 100644 --- a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -68,6 +68,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.InputStream; import java.lang.ref.WeakReference; +import java.net.URLEncoder; import java.util.ArrayList; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -293,13 +294,11 @@ public class ThumbnailsCacheManager { if (serverOCVersion.supportsRemoteThumbnails()) { GetMethod getMethod = null; try { - // resized image via gallery app - String uri = mClient.getBaseUri() + "/index.php/apps/gallery/api/preview/" + - Integer.parseInt(file.getRemoteId().substring(0, 8)) + "/" + pxW + "/" + pxH; - Log_OC.d(TAG, "generate resizedImage: " + file.getFileName() + " URI: " + uri); + String uri = mClient.getBaseUri() + "/index.php/core/preview.png?file=" + + URLEncoder.encode(file.getRemotePath()) + + "&x=" + pxW + "&y=" + pxH + "&a=1&mode=cover&forceIcon=0"; getMethod = new GetMethod(uri); - getMethod.setRequestHeader("Cookie", - "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true"); + int status = mClient.executeMethod(getMethod); if (status == HttpStatus.SC_OK) { InputStream inputStream = getMethod.getResponseBodyAsStream(); From d69fd2a98183c258d71ff63776cedaca1b8bc25b Mon Sep 17 00:00:00 2001 From: Tobias Kaminsky Date: Tue, 12 Dec 2017 00:49:16 +0100 Subject: [PATCH 18/18] daily dev 20171212 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index e61766e4f3..fd8b94b48f 100644 --- a/build.gradle +++ b/build.gradle @@ -107,8 +107,8 @@ android { versionDev { applicationId "com.nextcloud.android.beta" dimension "default" - versionCode 20171211 - versionName "20171211" + versionCode 20171212 + versionName "20171212" } }