-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b99a9b3
commit 5f0534a
Showing
63 changed files
with
4,212 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
app/src/main/java/moka/land/ui/samples/EncodingSampleLayout.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package moka.land.ui.samples | ||
|
||
import android.graphics.Bitmap | ||
import android.media.MediaMetadataRetriever | ||
import android.media.ThumbnailUtils | ||
import android.net.Uri | ||
import android.os.Build | ||
import android.os.Bundle | ||
import android.os.ParcelFileDescriptor | ||
import android.provider.MediaStore | ||
import android.util.Base64 | ||
import android.util.Log | ||
import android.util.Size | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import androidx.fragment.app.Fragment | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.navigation.fragment.findNavController | ||
import com.apollographql.apollo.ApolloClient | ||
import com.apollographql.apollo.api.FileUpload | ||
import com.bumptech.glide.Glide | ||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners | ||
import kotlinx.coroutines.launch | ||
import moka.land.R | ||
import moka.land.base.log | ||
import moka.land.databinding.LayoutEncodingSampleBinding | ||
import moka.land.imagehelper.picker.builder.ImagePicker | ||
import moka.land.imagehelper.picker.type.MediaType | ||
import moka.land.imagehelper.viewer.ImageViewer | ||
import moka.land.modules.awaitEnqueue | ||
import moka.land.transcoder.MediaTranscoder | ||
import moka.land.transcoder.format.MediaFormatStrategyPresets | ||
import moka.land.transcoder.utils.Thumbnail | ||
import moka.land.util.load | ||
import org.koin.android.ext.android.inject | ||
import java.io.ByteArrayOutputStream | ||
import java.io.File | ||
import java.io.FileNotFoundException | ||
import java.util.concurrent.Future | ||
|
||
|
||
class EncodingSampleLayout : Fragment() { | ||
|
||
private val _view by lazy { LayoutEncodingSampleBinding.inflate(layoutInflater) } | ||
private val apolloClient by inject<ApolloClient>() | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { | ||
initView() | ||
bindEvent() | ||
return _view.root | ||
} | ||
|
||
private fun initView() { | ||
} | ||
|
||
/* | ||
트랜스코더 https://pyxispub.uzuki.live/?p=174 | ||
*/ | ||
private fun bindEvent() { | ||
_view.imageViewBack.setOnClickListener { | ||
findNavController().navigateUp() | ||
} | ||
|
||
_view.textViewTestButton.setOnClickListener { | ||
ImagePicker | ||
.with(this) | ||
.setConfig { | ||
mediaType = MediaType.VIDEO_ONLY | ||
implicit = true | ||
} | ||
.showSingle { uri -> | ||
log("uri: ${uri}") | ||
Thumbnail.createBase64Thumbnail(uri) | ||
transcode(uri) | ||
} | ||
} | ||
|
||
_view.imageViewTarget.isEnabled = false | ||
_view.imageViewTarget.setOnClickListener { | ||
ImageViewer | ||
.with(activity!!) | ||
.show(arrayListOf(Uri.fromFile(file!!))) | ||
} | ||
} | ||
|
||
private var transcoderFuture: Future<Void>? = null | ||
private var file: File? = null | ||
|
||
private fun transcode(uri: Uri) { | ||
val parcelFileDescriptor = try { | ||
requireActivity().contentResolver.openFileDescriptor(uri, "r")!! | ||
} catch (e: FileNotFoundException) { | ||
Toast.makeText(this@EncodingSampleLayout.requireContext(), "File not found.", Toast.LENGTH_LONG).show() | ||
return | ||
} | ||
val fileDescriptor = parcelFileDescriptor.fileDescriptor | ||
|
||
val outputDir = File(requireActivity().getExternalFilesDir(null), "outputs") | ||
outputDir.mkdir() | ||
file = File.createTempFile("transcode_test", ".mp4", outputDir) | ||
|
||
transcoderFuture = MediaTranscoder | ||
.getInstance() | ||
.transcodeVideo( | ||
fileDescriptor, | ||
file!!.absolutePath, | ||
MediaFormatStrategyPresets.createAndroid720pStrategy(), | ||
object : MediaTranscoder.Listener { | ||
override fun onTranscodeProgress(progress: Double) { | ||
log("progress: ${progress}") | ||
} | ||
|
||
override fun onTranscodeCompleted() { | ||
log("onTranscodeCompleted is called") | ||
_view.imageViewTarget.load(requireActivity(), file) | ||
_view.imageViewTarget.isEnabled = true | ||
} | ||
|
||
override fun onTranscodeCanceled() { | ||
} | ||
|
||
override fun onTranscodeFailed(exception: Exception?) { | ||
log("onTranscodeFailed is called / ${exception?.message}") | ||
} | ||
} | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,20 +4,13 @@ import android.os.Bundle | |
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.core.net.toFile | ||
import androidx.fragment.app.Fragment | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.navigation.fragment.findNavController | ||
import io.moka.fileutil.FileUtil | ||
import kotlinx.coroutines.launch | ||
import moka.land.R | ||
import moka.land.base.log | ||
import moka.land.databinding.LayoutImagePickerSampleBinding | ||
import moka.land.imagehelper.picker.builder.ImagePicker | ||
import moka.land.imagehelper.picker.util.MediaLoader | ||
import moka.land.util.TakePictureUtil | ||
import moka.land.util.load | ||
import java.io.File | ||
|
||
class ImagePickerSampleLayout : Fragment() { | ||
|
||
|
@@ -50,7 +43,7 @@ class ImagePickerSampleLayout : Fragment() { | |
.showCamera { | ||
lifecycleScope.launch { | ||
// val uri = TakePictureUtil.save([email protected]!!, it) | ||
FileUtil.save(this@ImagePickerSampleLayout.activity!!, MediaLoader.getFile(this@ImagePickerSampleLayout.activity!!, it)) | ||
// FileUtil.save([email protected]!!, MediaLoader.getFile([email protected]!!, it)) | ||
// _view.imageViewTarget.load([email protected]!!, uri) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@color/white_01"> | ||
|
||
<ImageView | ||
android:id="@+id/imageViewBack" | ||
android:layout_width="?attr/actionBarSize" | ||
android:layout_height="?attr/actionBarSize" | ||
android:background="?attr/selectableItemBackgroundBorderless" | ||
android:padding="18dp" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:srcCompat="@drawable/mk_vc_left_arrow" /> | ||
|
||
<TextView | ||
android:id="@+id/textViewTitle" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="24dp" | ||
android:layout_marginTop="60dp" | ||
android:text="Video encoding test :)" | ||
android:textColor="@color/black_02" | ||
android:textSize="28dp" | ||
android:textStyle="bold" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="Libraries Samples" /> | ||
|
||
<TextView | ||
android:id="@+id/textViewTestButton" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="24dp" | ||
android:layout_marginTop="22dp" | ||
android:layout_marginRight="24dp" | ||
android:background="@color/white_02" | ||
android:elevation="2dp" | ||
android:foreground="?attr/selectableItemBackground" | ||
android:gravity="center" | ||
android:paddingLeft="24dp" | ||
android:paddingTop="16dp" | ||
android:paddingRight="24dp" | ||
android:paddingBottom="16dp" | ||
android:text="Video picker" | ||
android:textColor="@color/black_04" | ||
android:textSize="14dp" | ||
android:textStyle="bold" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/textViewTitle" | ||
tools:text="Libraries Samples" /> | ||
|
||
<ImageView | ||
android:id="@+id/imageViewTarget" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:layout_marginLeft="24dp" | ||
android:layout_marginTop="22dp" | ||
android:layout_marginRight="24dp" | ||
android:background="@color/black_10" | ||
app:layout_constraintDimensionRatio="1:1" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/textViewTestButton" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<manifest | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="moka.moka.dialog" /> | ||
package="moka.land.dialog" /> |
Oops, something went wrong.