Skip to content

Commit

Permalink
Merge pull request #109 from snuhcs-course/feat/android-video-limit
Browse files Browse the repository at this point in the history
�Show dialog for long videos
  • Loading branch information
thisisWooyeol authored Dec 6, 2023
2 parents db40a92 + f2a4610 commit fdfb444
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions android/app/src/main/java/com/goliath/emojihub/views/EmojiPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.goliath.emojihub.views

import android.Manifest
import android.content.pm.PackageManager
import android.media.MediaMetadataRetriever
import android.media.MediaMetadataRetriever.METADATA_KEY_DURATION
import android.util.Log
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.PickVisualMediaRequest
Expand Down Expand Up @@ -68,6 +70,7 @@ fun EmojiPage() {
val emojiList = emojiViewModel.emojiList.collectAsLazyPagingItems()

var showNonUserDialog by remember { mutableStateOf(false) }
var showVideoTooLongDialog by remember { mutableStateOf(false) }
var dropDownMenuExpanded by remember { mutableStateOf(false) }

val permissionLauncher = rememberLauncherForActivityResult(
Expand All @@ -79,8 +82,16 @@ fun EmojiPage() {
) { uri ->
if (uri != null) {
Log.d("PhotoPicker", "Selected URI: $uri")
emojiViewModel.videoUri = uri
navController.navigate(NavigationDestination.TransformVideo)
val retriever = MediaMetadataRetriever()
retriever.setDataSource(context, uri)
val duration = retriever.extractMetadata(METADATA_KEY_DURATION)?.toLongOrNull() ?: 0
retriever.release()
if (duration >= 6000) {
showVideoTooLongDialog = true
} else {
emojiViewModel.videoUri = uri
navController.navigate(NavigationDestination.TransformVideo)
}
}
}

Expand Down Expand Up @@ -175,6 +186,15 @@ fun EmojiPage() {
}
}

if (showVideoTooLongDialog) {
CustomDialog(
title = "안내",
body = "최대 5초 길이의 영상만 업로드할 수 있습니다.",
onDismissRequest = { showVideoTooLongDialog = false },
confirm = { showVideoTooLongDialog = false }
)
}

if (showNonUserDialog) {
CustomDialog(
title = "비회원 모드",
Expand Down

0 comments on commit fdfb444

Please sign in to comment.