@ -132,6 +132,7 @@ class ComposeActivity : BaseActivity(),
val viewModel : ComposeViewModel by viewModels { viewModelFactory }
val viewModel : ComposeViewModel by viewModels { viewModelFactory }
private var suggestFormattingSyntax : String = " text/markdown "
private var suggestFormattingSyntax : String = " text/markdown "
private val maxUploadMediaNumber = 4
private var mediaCount = 0
private var mediaCount = 0
public override fun onCreate ( savedInstanceState : Bundle ? ) {
public override fun onCreate ( savedInstanceState : Bundle ? ) {
@ -1073,6 +1074,8 @@ class ComposeActivity : BaseActivity(),
intent . putExtra ( Intent . EXTRA _MIME _TYPES , mimeTypes )
intent . putExtra ( Intent . EXTRA _MIME _TYPES , mimeTypes )
}
}
intent . type = " */* "
intent . type = " */* "
intent . putExtra ( Intent . EXTRA _MIME _TYPES , mimeTypes )
intent . putExtra ( Intent . EXTRA _ALLOW _MULTIPLE , true )
startActivityForResult ( intent , MEDIA _PICK _RESULT )
startActivityForResult ( intent , MEDIA _PICK _RESULT )
}
}
@ -1099,7 +1102,23 @@ class ComposeActivity : BaseActivity(),
override fun onActivityResult ( requestCode : Int , resultCode : Int , intent : Intent ? ) {
override fun onActivityResult ( requestCode : Int , resultCode : Int , intent : Intent ? ) {
super . onActivityResult ( requestCode , resultCode , intent )
super . onActivityResult ( requestCode , resultCode , intent )
if ( resultCode == Activity . RESULT _OK && requestCode == MEDIA _PICK _RESULT && intent != null ) {
if ( resultCode == Activity . RESULT _OK && requestCode == MEDIA _PICK _RESULT && intent != null ) {
if ( intent . data != null ) {
// Single media, upload it and done.
pickMedia ( intent . data !! )
pickMedia ( intent . data !! )
} else if ( intent . clipData != null ) {
val clipData = intent . clipData !!
val count = clipData . itemCount
if ( mediaCount + count > maxUploadMediaNumber ) {
// check if exist media + upcoming media > 4, then prob error message.
Toast . makeText ( this , getString ( R . string . error _upload _max _media _reached , maxUploadMediaNumber ) , Toast . LENGTH _SHORT ) . show ( )
} else {
// if not grater then 4, upload all multiple media.
for ( i in 0 until count ) {
val imageUri = clipData . getItemAt ( i ) . getUri ( )
pickMedia ( imageUri )
}
}
}
} else if ( resultCode == Activity . RESULT _OK && requestCode == MEDIA _TAKE _PHOTO _RESULT ) {
} else if ( resultCode == Activity . RESULT _OK && requestCode == MEDIA _TAKE _PHOTO _RESULT ) {
pickMedia ( photoUploadUri !! )
pickMedia ( photoUploadUri !! )
}
}