Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show dialog for long videos #109

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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