From e96a16b09b257bb1a18814b93f4b70273486d494 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 5 Nov 2014 14:51:59 +0100 Subject: [PATCH 1/4] allows multiselect during upload for select applications --- .../android/ui/activity/FileDisplayActivity.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index b5d543a4e2..4b3dddbf85 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -25,6 +25,7 @@ import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; +import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; @@ -598,8 +599,15 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { super.onActivityResult(requestCode, resultCode, data); if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) { - requestSimpleUpload(data, resultCode); - + if (data.getData() == null){ + for( int i = 0; i < data.getClipData().getItemCount(); i++){ + Intent intent = new Intent(); + intent.setData(data.getClipData().getItemAt(i).getUri()); + requestSimpleUpload(intent, resultCode); + } + }else { + requestSimpleUpload(data, resultCode); + } } else if (requestCode == ACTION_SELECT_MULTIPLE_FILES && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) { requestMultipleUpload(data, resultCode); @@ -838,6 +846,7 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); + action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)), ACTION_SELECT_CONTENT_FROM_APPS); } From 0ba228c064d38b59ee17412d82259804bb8dd96f Mon Sep 17 00:00:00 2001 From: Pro9 Date: Fri, 7 Nov 2014 09:25:31 +0100 Subject: [PATCH 2/4] Added an api check, since multiselect only works on api level 18+ --- .../android/ui/activity/FileDisplayActivity.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 4b3dddbf85..f796aa4f88 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -26,6 +26,7 @@ import android.accounts.AccountManager; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.annotation.SuppressLint; +import android.annotation.TargetApi; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; @@ -42,6 +43,7 @@ import android.content.SyncRequest; import android.content.res.Resources.NotFoundException; import android.database.Cursor; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.preference.PreferenceManager; @@ -594,12 +596,15 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { /** * Called, when the user selected something for uploading + * */ + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) { - if (data.getData() == null){ + //getClipData is only supported on api level 16+ + if (data.getData() == null && Build.VERSION.SDK_INT >= 16){ for( int i = 0; i < data.getClipData().getItemCount(); i++){ Intent intent = new Intent(); intent.setData(data.getClipData().getItemAt(i).getUri()); @@ -846,7 +851,10 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); - action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); + //putExtra is only supported on api level 18+ + if(Build.VERSION.SDK_INT >= 18) { + action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); + } startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)), ACTION_SELECT_CONTENT_FROM_APPS); } From c2ee5dbff97aac76fe4fce7069709ac24cdeb0db Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 5 Nov 2014 14:51:59 +0100 Subject: [PATCH 3/4] This commit targets https://github.com/owncloud/android/issues/596 1. allows multiselect during upload for select applications 2. Added an api check, multiselect is only supported on api level 18+ --- .../ui/activity/FileDisplayActivity.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index b5d543a4e2..a5b324f386 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -25,6 +25,8 @@ import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; +import android.annotation.SuppressLint; +import android.annotation.TargetApi; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; @@ -41,6 +43,7 @@ import android.content.SyncRequest; import android.content.res.Resources.NotFoundException; import android.database.Cursor; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.preference.PreferenceManager; @@ -593,13 +596,23 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { /** * Called, when the user selected something for uploading + * */ + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) { - requestSimpleUpload(data, resultCode); - + //getClipData is only supported on api level 16+ + if (data.getData() == null && Build.VERSION.SDK_INT >= 16){ + for( int i = 0; i < data.getClipData().getItemCount(); i++){ + Intent intent = new Intent(); + intent.setData(data.getClipData().getItemAt(i).getUri()); + requestSimpleUpload(intent, resultCode); + } + }else { + requestSimpleUpload(data, resultCode); + } } else if (requestCode == ACTION_SELECT_MULTIPLE_FILES && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) { requestMultipleUpload(data, resultCode); @@ -838,6 +851,10 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); + //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+ + if(Build.VERSION.SDK_INT >= 18) { + action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); + } startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)), ACTION_SELECT_CONTENT_FROM_APPS); } From 1a6319eba40ee31ef0f3cf3b4e0f797a80c4ac0b Mon Sep 17 00:00:00 2001 From: Magnus Sjoqvist Date: Tue, 2 Dec 2014 11:11:34 +0100 Subject: [PATCH 4/4] Removes build version magic numbers --- .../owncloud/android/ui/activity/FileDisplayActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index a5b324f386..2223971e83 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -603,8 +603,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { super.onActivityResult(requestCode, resultCode, data); if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) { - //getClipData is only supported on api level 16+ - if (data.getData() == null && Build.VERSION.SDK_INT >= 16){ + //getClipData is only supported on api level 16+, Jelly Bean + if (data.getData() == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){ for( int i = 0; i < data.getClipData().getItemCount(); i++){ Intent intent = new Intent(); intent.setData(data.getClipData().getItemAt(i).getUri()); @@ -851,8 +851,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); - //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+ - if(Build.VERSION.SDK_INT >= 18) { + //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)),