@@ -684,17 +684,64 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
684
684
685
685
private fun receiveInternalSharedItems () {
686
686
val intent = intent
687
+ Timber .d(" Intent has EXTRA_FILES: ${EXTRA_FILES } " )
688
+ uploadableFiles = try {
689
+ // Check if intent has the extra before trying to read it
690
+ if (! intent.hasExtra(EXTRA_FILES )) {
691
+ Timber .w(" No EXTRA_FILES found in intent" )
692
+ mutableListOf ()
693
+ } else {
694
+ // Try to get the files as Parcelable array
695
+ val files = if (VERSION .SDK_INT >= VERSION_CODES .TIRAMISU ) {
696
+ intent.getParcelableArrayListExtra(EXTRA_FILES , UploadableFile ::class .java)
697
+ } else {
698
+ @Suppress(" DEPRECATION" )
699
+ intent.getParcelableArrayListExtra<UploadableFile >(EXTRA_FILES )
700
+ }
701
+
702
+ // Convert to mutable list or return empty list if null
703
+ files?.toMutableList() ? : run {
704
+ Timber .w(" Files array was null" )
705
+ mutableListOf ()
706
+ }
707
+ }
708
+ } catch (e: Exception ) {
709
+ Timber .e(e, " Error reading files from intent" )
710
+ mutableListOf ()
711
+ }
712
+
713
+ // Log the result for debugging
714
+ isMultipleFilesSelected = uploadableFiles.size > 1
715
+ Timber .i(" Received files count: ${uploadableFiles.size} " )
716
+ uploadableFiles.forEachIndexed { index, file ->
717
+ Timber .d(" File $index path: ${file.getFilePath()} " )
718
+ }
687
719
688
- Timber .d(" Received intent %s with action %s" , intent.toString(), intent.action)
720
+ // Handle other extras with null safety
721
+ place = try {
722
+ if (VERSION .SDK_INT >= VERSION_CODES .TIRAMISU ) {
723
+ intent.getParcelableExtra(PLACE_OBJECT , Place ::class .java)
724
+ } else {
725
+ @Suppress(" DEPRECATION" )
726
+ intent.getParcelableExtra(PLACE_OBJECT )
727
+ }
728
+ } catch (e: Exception ) {
729
+ Timber .e(e, " Error reading place" )
730
+ null
731
+ }
689
732
690
- uploadableFiles = mutableListOf<UploadableFile >().apply {
691
- addAll(intent.getParcelableArrayListExtra(EXTRA_FILES ) ? : emptyList())
733
+ prevLocation = try {
734
+ if (VERSION .SDK_INT >= VERSION_CODES .TIRAMISU ) {
735
+ intent.getParcelableExtra(LOCATION_BEFORE_IMAGE_CAPTURE , LatLng ::class .java)
736
+ } else {
737
+ @Suppress(" DEPRECATION" )
738
+ intent.getParcelableExtra(LOCATION_BEFORE_IMAGE_CAPTURE )
739
+ }
740
+ } catch (e: Exception ) {
741
+ Timber .e(e, " Error reading location" )
742
+ null
692
743
}
693
- isMultipleFilesSelected = uploadableFiles!! .size > 1
694
- Timber .i(" Received multiple upload %s" , uploadableFiles!! .size)
695
744
696
- place = intent.getParcelableExtra<Place >(PLACE_OBJECT )
697
- prevLocation = intent.getParcelableExtra(LOCATION_BEFORE_IMAGE_CAPTURE )
698
745
isInAppCameraUpload = intent.getBooleanExtra(IN_APP_CAMERA_UPLOAD , false )
699
746
resetDirectPrefs()
700
747
}
@@ -803,6 +850,7 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
803
850
/* *
804
851
* Overrides the back button to make sure the user is prepared to lose their progress
805
852
*/
853
+ @SuppressLint(" MissingSuperCall" )
806
854
override fun onBackPressed () {
807
855
showAlertDialog(
808
856
this ,
@@ -920,7 +968,7 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
920
968
921
969
companion object {
922
970
private var uploadIsOfAPlace = false
923
- const val EXTRA_FILES : String = " commons_image_exta "
971
+ const val EXTRA_FILES : String = " commons_image_extra "
924
972
const val LOCATION_BEFORE_IMAGE_CAPTURE : String = " user_location_before_image_capture"
925
973
const val IN_APP_CAMERA_UPLOAD : String = " in_app_camera_upload"
926
974
0 commit comments