mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 06:15:12 +00:00
add direct video upload
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
53e3543839
commit
b064190d35
@ -253,6 +253,9 @@
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<data android:mimeType="*/*" />
|
||||
</intent>
|
||||
<intent>
|
||||
<action android:name="android.media.action.VIDEO_CAPTURE" />
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
</manifest>
|
||||
|
@ -51,6 +51,7 @@ import android.os.SystemClock
|
||||
import android.os.VibrationEffect
|
||||
import android.os.Vibrator
|
||||
import android.provider.ContactsContract
|
||||
import android.provider.MediaStore
|
||||
import android.text.Editable
|
||||
import android.text.InputFilter
|
||||
import android.text.TextUtils
|
||||
@ -204,6 +205,7 @@ import java.io.IOException
|
||||
import java.net.HttpURLConnection
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.Objects
|
||||
import java.util.concurrent.ExecutionException
|
||||
import javax.inject.Inject
|
||||
@ -1089,8 +1091,7 @@ class ChatController(args: Bundle) :
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun setVoiceRecordFileName() {
|
||||
val pattern = "yyyy-MM-dd HH-mm-ss"
|
||||
val simpleDateFormat = SimpleDateFormat(pattern)
|
||||
val simpleDateFormat = SimpleDateFormat(FILE_DATE_PATTERN)
|
||||
val date: String = simpleDateFormat.format(Date())
|
||||
|
||||
val fileNameWithoutSuffix = String.format(
|
||||
@ -3253,6 +3254,28 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
}
|
||||
|
||||
fun sendVideoFromCamIntent() {
|
||||
Intent(MediaStore.ACTION_VIDEO_CAPTURE).also { takeVideoIntent ->
|
||||
takeVideoIntent.resolveActivity(activity!!.packageManager)?.also {
|
||||
val videoFile: File? = try {
|
||||
val outputDir = context.cacheDir
|
||||
val dateFormat = SimpleDateFormat(FILE_DATE_PATTERN, Locale.ROOT)
|
||||
val date = dateFormat.format(Date())
|
||||
File("$outputDir/$VIDEO_PREFIX_PART$date$VIDEO_SUFFIX")
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, "error while creating video file", e)
|
||||
null
|
||||
}
|
||||
|
||||
videoFile?.also {
|
||||
val videoURI: Uri = FileProvider.getUriForFile(context, context.packageName, it)
|
||||
takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, videoURI)
|
||||
startActivityForResult(takeVideoIntent, REQUEST_CODE_PICK_CAMERA)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun createPoll() {
|
||||
val pollVoteDialog = PollCreateDialogFragment.newInstance(
|
||||
roomToken!!
|
||||
@ -3288,6 +3311,9 @@ class ChatController(args: Bundle) :
|
||||
private const val VOICE_RECORD_CANCEL_SLIDER_X: Int = -50
|
||||
private const val VOICE_MESSAGE_META_DATA = "{\"messageType\":\"voice-message\"}"
|
||||
private const val VOICE_MESSAGE_FILE_SUFFIX = ".mp3"
|
||||
private const val FILE_DATE_PATTERN = "yyyy-MM-dd HH-mm-ss"
|
||||
private const val VIDEO_PREFIX_PART = "Talk Video "
|
||||
private const val VIDEO_SUFFIX = ".mp4"
|
||||
private const val SHORT_VIBRATE: Long = 20
|
||||
private const val FULLY_OPAQUE_INT: Int = 255
|
||||
private const val SEMI_TRANSPARENT_INT: Int = 99
|
||||
|
@ -23,6 +23,7 @@
|
||||
package com.nextcloud.talk.ui.dialog
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -81,6 +82,10 @@ class AttachmentDialog(val activity: Activity, var chatController: ChatControlle
|
||||
if (!CapabilitiesUtilNew.hasSpreedFeatureCapability(chatController.conversationUser, "talk-polls")) {
|
||||
dialogAttachmentBinding.menuAttachPoll.visibility = View.GONE
|
||||
}
|
||||
|
||||
if (!context.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) {
|
||||
dialogAttachmentBinding.menuAttachVideoFromCam.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun initItemsClickListeners() {
|
||||
@ -99,6 +104,11 @@ class AttachmentDialog(val activity: Activity, var chatController: ChatControlle
|
||||
dismiss()
|
||||
}
|
||||
|
||||
dialogAttachmentBinding.menuAttachVideoFromCam.setOnClickListener {
|
||||
chatController.sendVideoFromCamIntent()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
dialogAttachmentBinding.menuAttachPoll.setOnClickListener {
|
||||
chatController.createPoll()
|
||||
dismiss()
|
||||
|
5
app/src/main/res/drawable/ic_baseline_videocam_24.xml
Normal file
5
app/src/main/res/drawable/ic_baseline_videocam_24.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M17,10.5V7c0,-0.55 -0.45,-1 -1,-1H4c-0.55,0 -1,0.45 -1,1v10c0,0.55 0.45,1 1,1h12c0.55,0 1,-0.45 1,-1v-3.5l4,4v-11l-4,4z"/>
|
||||
</vector>
|
@ -171,6 +171,39 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/menu_attach_video_from_cam"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_item_height"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/standard_padding"
|
||||
android:paddingEnd="@dimen/standard_padding"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/menu_icon_attach_video_from_cam"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/ic_baseline_videocam_24"
|
||||
app:tint="@color/high_emphasis_menu_icon" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/txt_attach_video_from_cam"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:paddingStart="@dimen/standard_double_padding"
|
||||
android:paddingEnd="@dimen/zero"
|
||||
android:text="@string/nc_upload_video_from_cam"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="@color/high_emphasis_text"
|
||||
android:textSize="@dimen/bottom_sheet_text_size" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/menu_attach_file_from_local"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -416,6 +416,7 @@
|
||||
<!-- Upload -->
|
||||
<string name="nc_add_file">Add to conversation</string>
|
||||
<string name="nc_upload_picture_from_cam">Take photo</string>
|
||||
<string name="nc_upload_video_from_cam">Take video</string>
|
||||
<string name="nc_create_poll">Create poll</string>
|
||||
<string name="nc_upload_from_cloud">Share from %1$s</string>
|
||||
<string name="nc_upload_failed">Sorry, upload failed</string>
|
||||
|
Loading…
Reference in New Issue
Block a user