From 93d7c7f9f7c8af2043d8459af123f06fe1d0c03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Mon, 10 Jan 2022 18:11:13 +0100 Subject: [PATCH 1/4] IntentUtil: fix sending multiple files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use `ACTION_SEND_MULTIPLE` - Set type to `*/*` if not all files share a type - Use use a `ParcelableArrayListExtra` for `EXTRA_STREAM` Signed-off-by: Álvaro Brey Vilas --- .../java/com/nextcloud/client/utils/IntentUtil.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/nextcloud/client/utils/IntentUtil.kt b/src/main/java/com/nextcloud/client/utils/IntentUtil.kt index 19bcd366f0..da32a88ed6 100644 --- a/src/main/java/com/nextcloud/client/utils/IntentUtil.kt +++ b/src/main/java/com/nextcloud/client/utils/IntentUtil.kt @@ -30,6 +30,7 @@ object IntentUtil { @JvmStatic public fun createSendIntent(context: Context, file: OCFile): Intent = createBaseSendFileIntent().apply { + action = Intent.ACTION_SEND type = file.mimeType putExtra(Intent.EXTRA_STREAM, file.getExposedFileUri(context)) } @@ -37,20 +38,21 @@ object IntentUtil { @JvmStatic public fun createSendIntent(context: Context, files: Array): Intent = createBaseSendFileIntent().apply { + action = Intent.ACTION_SEND_MULTIPLE type = getUniqueMimetype(files) - putExtra(Intent.EXTRA_STREAM, getExposedFileUris(context, files)) + putParcelableArrayListExtra(Intent.EXTRA_STREAM, getExposedFileUris(context, files)) } private fun createBaseSendFileIntent(): Intent = - Intent(Intent.ACTION_SEND).apply { + Intent().apply { addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) } private fun getUniqueMimetype(files: Array): String? = when { - files.distinctBy { it.mimeType }.size > 1 -> null + files.distinctBy { it.mimeType }.size > 1 -> "*/*" else -> files[0].mimeType } - private fun getExposedFileUris(context: Context, files: Array): Array = - files.map { it.getExposedFileUri(context) }.toTypedArray() + private fun getExposedFileUris(context: Context, files: Array): ArrayList = + ArrayList(files.map { it.getExposedFileUri(context) }) } From 61f8115d79549680161ccc9c7352413e08c95532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Mon, 10 Jan 2022 18:31:05 +0100 Subject: [PATCH 2/4] SendFilesDialog: Show error if no app can send multiple files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise an empty bottom fragment shows up, which is not good UX Signed-off-by: Álvaro Brey Vilas --- .../owncloud/android/ui/dialog/SendFilesDialog.java | 13 ++++++++++--- src/main/res/values/strings.xml | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/dialog/SendFilesDialog.java b/src/main/java/com/owncloud/android/ui/dialog/SendFilesDialog.java index 8ab51fa98e..b38bde87d6 100644 --- a/src/main/java/com/owncloud/android/ui/dialog/SendFilesDialog.java +++ b/src/main/java/com/owncloud/android/ui/dialog/SendFilesDialog.java @@ -9,6 +9,7 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.nextcloud.client.utils.IntentUtil; @@ -82,8 +83,14 @@ public class SendFilesDialog extends BottomSheetDialogFragment { // populate send apps Intent sendIntent = IntentUtil.createSendIntent(requireContext(), files); + List matches = requireActivity().getPackageManager().queryIntentActivities(sendIntent, 0); + if (matches.isEmpty()) { + Toast.makeText(getContext(), R.string.no_send_app, Toast.LENGTH_SHORT).show(); + dismiss(); + return null; + } - List sendButtonDataList = setupSendButtonData(sendIntent); + List sendButtonDataList = setupSendButtonData(matches); SendButtonAdapter.ClickListener clickListener = setupSendButtonClickListener(sendIntent); @@ -108,11 +115,11 @@ public class SendFilesDialog extends BottomSheetDialogFragment { } @NonNull - private List setupSendButtonData(Intent sendIntent) { + private List setupSendButtonData(List matches) { Drawable icon; SendButtonData sendButtonData; CharSequence label; - List matches = requireActivity().getPackageManager().queryIntentActivities(sendIntent, 0); + List sendButtonDataList = new ArrayList<>(matches.size()); for (ResolveInfo match : matches) { icon = match.loadIcon(requireActivity().getPackageManager()); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 81ecd3c3a9..fd820068e3 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -1006,4 +1006,5 @@ No results found for your query Found no images or videos Error creating file from template + No app available for sending the selected files From 9d856da33a95e6a96e2132262a2f454bbfef84d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Wed, 12 Jan 2022 14:51:34 +0100 Subject: [PATCH 3/4] Improve testing for SendFilesDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add tests for mixed type files * Add integration tests, not only screenshot Signed-off-by: Álvaro Brey Vilas --- ...t_showDialogDifferentTypes_Screenshot.png} | Bin ...dFilesDialogTest_showDialog_Screenshot.png | Bin 0 -> 19949 bytes .../android/ui/dialog/SendFilesDialogTest.kt | 68 ++++++++++++++---- 3 files changed, 55 insertions(+), 13 deletions(-) rename screenshots/gplay/debug/{com.owncloud.android.ui.dialog.SendFilesDialogTest_showDialog.png => com.owncloud.android.ui.dialog.SendFilesDialogTest_showDialogDifferentTypes_Screenshot.png} (100%) create mode 100644 screenshots/gplay/debug/com.owncloud.android.ui.dialog.SendFilesDialogTest_showDialog_Screenshot.png diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.dialog.SendFilesDialogTest_showDialog.png b/screenshots/gplay/debug/com.owncloud.android.ui.dialog.SendFilesDialogTest_showDialogDifferentTypes_Screenshot.png similarity index 100% rename from screenshots/gplay/debug/com.owncloud.android.ui.dialog.SendFilesDialogTest_showDialog.png rename to screenshots/gplay/debug/com.owncloud.android.ui.dialog.SendFilesDialogTest_showDialogDifferentTypes_Screenshot.png diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.dialog.SendFilesDialogTest_showDialog_Screenshot.png b/screenshots/gplay/debug/com.owncloud.android.ui.dialog.SendFilesDialogTest_showDialog_Screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..bd3d20143bc504a284f67fefdb7eedafc68388ae GIT binary patch literal 19949 zcmeFZcT|&G*Dq?_?2Q7t5fBhi*@{v{q=up(vK0ZPcLYQ_krDzVknL6!sWys~ARxU7 zp#~C^76l>nPNGBzB#;;gNl3lf-}jySo-^(k?-=)van2uieE+WTtTpGF>o@0`YnJEv z9a}3gQ903l`}T?5{PVi~zJ2@Y`}Q5Y_UkXg5oz1o0sHpZwA{RY%`t9ab6Mms&j6JE zH$fQQhWcCZi(^-VZ(Tih{gC6KYpbMz*!l~pUS^GR4PLYw*K5}sQ&DLtVvbi2?GK&+ zJh__Ce6b)5Uj)P<00>0ENW`xjrdi_iMQu7n6CxKEJNo7Dz7NB-&A;xu`tIPq0}A_& zt?&Ems>r@a;`@G$`5$A4jP{)#+y7r<|MkItj{R?)BwYL-R{ll(U+f9T{>7esdXGWa)?{twIGe}LitDed3@Ug->K?&ve}m`$ z^IiA0%HCt_@~9;=K#*VYx2#%b16cj{0Qf-H<%s?Jg3?^_r*zdx6w z--aQ9ie73No5ngi-In!{L{!XR&;@7T- zFujh4FDuORE`Chg9^ct%&e5IU@~KtK^kLv!Ue~71ZZS9GR!uSen=fCNHJA39FK-MR zE2X)#3|P9TXZd)c)fbFJ&lP4}$caNUbLpJaX@&VMhKOE2wSf|U1LUOX&0ngfDPe3f zWnYs;1K@}|$Jak7*N23sg1vX@J7VWeP=M_e&+o9k&rAsJ4zpbJqdtZ0U+B}Jpu2jL zmf=5|{u`)FW2tD0RFTPAKP)kr0oKp{-8ffmdWn6j^P!I>eh1hT;iA67FhBea(&O_x zp0oVQAWSe$>j4(a5UgB0I)06rJFb~X&ta{LnPq0zliL;`-Y9y50b@l16POhTD!jtE zb0l76r@g=hV`%1itab*JV-C4$qS2*x4j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-lX?+o<>}^e`OAMdei?Es{>U0@bGZGjx|#jjI(j$Mp>|6ftN_^ z*|SGqhG7^M(97WU>(?@D*f8&Xa&oc;35P%MQ)wgh63l@BfH{lm510J(>C?4(KXT-V zKAcG&xW5q`nl^1JQ>RYVAlj)@r(&NWS);}<4+MN*j&O`a|Ni~u#EBCcz=sSOqSAdy zP_+}}k;)w-M~>8c`ysJoOsa7QiN?&CGgZbXc_?!R1{|2}48t%ipa%fC6`ntT zuDwm(XJ=>Yu^BUFsMKB&e*XL^%a<>g8#ivq;K75XPMtbZty(o(AwdTBH?5EK^mJ+4 zwyk%Z771+-df9&by=np{$(O6(ORJoj&#G0cddEoWTw>=SnAfjgzu0-G0<1Bo43#ww zNuo*YhGAGhF9$p@spc@eb?)3*AHL4GMgXWNj~_o)ITs@pRXfldHG&KChkTB=0eRbB z*?#@{RTUSP#QC95PJ3j`m@z81vnKrJMnBx^#ful3B-E-^OOGMRW0dqO11JU(*M0Q@PV?M=i~7e#YnLP?C268SPn{s`59qC0wbE*T%a$#=1rpVUJ?a?m zoUej&aNXm%ASu9;;SxY3c}$q}<|j^^sN)X@2%*b~&_ zFYp_lsb;X_*`{{lGKQAhlhJLa-w%a&=soFGkL#wf=h6~bMP zqZ}~F4Ie&S``z@?F}@L0og`1doi%Hg?n}od&-OF=?qkP}E%rTN)T3X{xXz@%pcuzB-lHP(?RP?5Xund?(iQ)Tz=-Krc78Z=1z?}lL*7SKz8{pD0#NSqL;NBV33 z6(bZcKU7%$ph87XFV(;QJkYuRe;a=fwwMJ{NciJGzb09$R;^M)8(YSljE%W*z<>eX zc~shL4|7mG=jP^Wh0MBel{MpHazw@P_s{)vi9C-g;DYq8(mDImQ3~jnyUN@TsuA1T zSeJaxnxxt{48yR1UIu|4s+EC0X`orIgM``QM@9QuO!?1vE m7=~dOh6QxPFbu=^o%jQVxTtsK0e$`e0000): SendFilesDialog { + val activity = testActivityRule.launchActivity(null) + + val fm: FragmentManager = activity.supportFragmentManager + val ft = fm.beginTransaction() + ft.addToBackStack(null) val sut = SendFilesDialog.newInstance(files) sut.show(ft, "TAG_SEND_SHARE_DIALOG") @@ -59,6 +73,34 @@ class SendFilesDialogTest : AbstractIT() { InstrumentationRegistry.getInstrumentation().waitForIdleSync() shortSleep() + return sut + } + + @Test + fun showDialog() { + val sut = showDialog(FILES_SAME_TYPE) + val recyclerview: RecyclerView = sut.requireDialog().findViewById(R.id.send_button_recycler_view) + Assert.assertNotEquals("Send button list is empty", 0, recyclerview.adapter?.itemCount) + } + + @Test + @ScreenshotTest + fun showDialog_Screenshot() { + val sut = showDialog(FILES_SAME_TYPE) + sut.requireDialog().window?.decorView.let { screenshot(it) } + } + + @Test + fun showDialogDifferentTypes() { + val sut = showDialog(FILES_MIXED_TYPE) + val recyclerview: RecyclerView = sut.requireDialog().findViewById(R.id.send_button_recycler_view) + Assert.assertNotEquals("Send button list is empty", 0, recyclerview.adapter?.itemCount) + } + + @Test + @ScreenshotTest + fun showDialogDifferentTypes_Screenshot() { + val sut = showDialog(FILES_MIXED_TYPE) sut.requireDialog().window?.decorView.let { screenshot(it) } } } From 53feb147147c857ea633da6b822474a84da9e9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Thu, 13 Jan 2022 09:06:09 +0100 Subject: [PATCH 4/4] SendFilesDialogTest: assert adapter is not null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just in case Signed-off-by: Álvaro Brey Vilas --- .../com/owncloud/android/ui/dialog/SendFilesDialogTest.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/androidTest/java/com/owncloud/android/ui/dialog/SendFilesDialogTest.kt b/src/androidTest/java/com/owncloud/android/ui/dialog/SendFilesDialogTest.kt index 321a2e770b..79c915789c 100644 --- a/src/androidTest/java/com/owncloud/android/ui/dialog/SendFilesDialogTest.kt +++ b/src/androidTest/java/com/owncloud/android/ui/dialog/SendFilesDialogTest.kt @@ -80,7 +80,8 @@ class SendFilesDialogTest : AbstractIT() { fun showDialog() { val sut = showDialog(FILES_SAME_TYPE) val recyclerview: RecyclerView = sut.requireDialog().findViewById(R.id.send_button_recycler_view) - Assert.assertNotEquals("Send button list is empty", 0, recyclerview.adapter?.itemCount) + Assert.assertNotNull("Adapter is null", recyclerview.adapter) + Assert.assertNotEquals("Send button list is empty", 0, recyclerview.adapter!!.itemCount) } @Test @@ -94,7 +95,8 @@ class SendFilesDialogTest : AbstractIT() { fun showDialogDifferentTypes() { val sut = showDialog(FILES_MIXED_TYPE) val recyclerview: RecyclerView = sut.requireDialog().findViewById(R.id.send_button_recycler_view) - Assert.assertNotEquals("Send button list is empty", 0, recyclerview.adapter?.itemCount) + Assert.assertNotNull("Adapter is null", recyclerview.adapter) + Assert.assertNotEquals("Send button list is empty", 0, recyclerview.adapter!!.itemCount) } @Test