multiple media upload support (#2029)
* multiple media upload support * multiple media upload support * multiple media upload support * remove typing * Update app/src/main/res/values/strings.xml Co-authored-by: Konrad Pozniak <connyduck@users.noreply.github.com> * remove magic number on string.xml and add to activity. Co-authored-by: Konrad Pozniak <connyduck@users.noreply.github.com>
This commit is contained in:
parent
08c8aee553
commit
d7ec778fd9
@ -132,6 +132,7 @@ class ComposeActivity : BaseActivity(),
|
||||
val viewModel: ComposeViewModel by viewModels { viewModelFactory }
|
||||
private var suggestFormattingSyntax: String = "text/markdown"
|
||||
|
||||
private val maxUploadMediaNumber = 4
|
||||
private var mediaCount = 0
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -1073,6 +1074,8 @@ class ComposeActivity : BaseActivity(),
|
||||
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
|
||||
}
|
||||
intent.type = "*/*"
|
||||
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
|
||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
||||
startActivityForResult(intent, MEDIA_PICK_RESULT)
|
||||
}
|
||||
|
||||
@ -1099,7 +1102,23 @@ class ComposeActivity : BaseActivity(),
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, intent)
|
||||
if (resultCode == Activity.RESULT_OK && requestCode == MEDIA_PICK_RESULT && intent != null) {
|
||||
pickMedia(intent.data!!)
|
||||
if(intent.data != null){
|
||||
// Single media, upload it and done.
|
||||
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) {
|
||||
pickMedia(photoUploadUri!!)
|
||||
}
|
||||
|
@ -595,6 +595,7 @@
|
||||
<string name="limit_notifications">Limit timeline notifications</string>
|
||||
<string name="wellbeing_hide_stats_posts">Hide quantitative stats on posts</string>
|
||||
<string name="wellbeing_hide_stats_profile">Hide quantitative stats on profiles</string>
|
||||
<string name="error_upload_max_media_reached">You cannot upload more than %1$d media attachments.</string>
|
||||
|
||||
<string name="wellbeing_mode_notice">Some information that might affect your mental wellbeing will be hidden. This includes:\n\n
|
||||
- Favorite/Boost/Follow notifications\n
|
||||
|
Loading…
Reference in New Issue
Block a user