|
|
|
@ -1,10 +1,12 @@ |
|
|
|
package net.pokeranalytics.android.ui.modules.handhistory |
|
|
|
package net.pokeranalytics.android.ui.modules.handhistory |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.Manifest |
|
|
|
import android.animation.ValueAnimator |
|
|
|
import android.animation.ValueAnimator |
|
|
|
import android.app.Activity |
|
|
|
import android.app.Activity |
|
|
|
import android.app.AlertDialog |
|
|
|
import android.app.AlertDialog |
|
|
|
import android.content.Intent |
|
|
|
import android.content.Intent |
|
|
|
import android.graphics.Bitmap |
|
|
|
import android.graphics.Bitmap |
|
|
|
|
|
|
|
import android.graphics.Canvas |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Handler |
|
|
|
import android.os.Handler |
|
|
|
import android.view.* |
|
|
|
import android.view.* |
|
|
|
@ -701,8 +703,8 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
builder.setTitle(R.string.export) |
|
|
|
builder.setTitle(R.string.export) |
|
|
|
builder.setItems( |
|
|
|
builder.setItems( |
|
|
|
arrayOf<CharSequence>( |
|
|
|
arrayOf<CharSequence>( |
|
|
|
getString(R.string.text) |
|
|
|
getString(R.string.text), |
|
|
|
// getString(R.string.video), |
|
|
|
getString(R.string.video) |
|
|
|
// "GIF" |
|
|
|
// "GIF" |
|
|
|
) |
|
|
|
) |
|
|
|
) { _, index -> |
|
|
|
) { _, index -> |
|
|
|
@ -710,7 +712,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
// of the selected item |
|
|
|
// of the selected item |
|
|
|
when (index) { |
|
|
|
when (index) { |
|
|
|
0 -> this.textExport() |
|
|
|
0 -> this.textExport() |
|
|
|
1 -> this.videoExport() |
|
|
|
1 -> this.videoExportAskForPermission() |
|
|
|
2 -> this.gifExport() |
|
|
|
2 -> this.gifExport() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -718,31 +720,36 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun videoExportAskForPermission() { |
|
|
|
|
|
|
|
askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, RequestCode.PERMISSION_WRITE_EXTERNAL_STORAGE.value) { granted -> |
|
|
|
|
|
|
|
if (granted) { |
|
|
|
|
|
|
|
videoExport() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun videoExport() { |
|
|
|
private fun videoExport() { |
|
|
|
|
|
|
|
|
|
|
|
val config = ReplayerAnimator(this.model.handHistory) |
|
|
|
val animator = ReplayerAnimator(this.model.handHistory, true) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val square = 1024f |
|
|
|
|
|
|
|
|
|
|
|
val width = 480 |
|
|
|
val width = square |
|
|
|
val height = 480 |
|
|
|
val height = square |
|
|
|
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) |
|
|
|
|
|
|
|
val tc = TableDrawer(bitmap) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// draw initial table |
|
|
|
animator.setDimension(width, height) |
|
|
|
// TableDrawer.initializeTable(config, tc, requireContext()) |
|
|
|
TableDrawer.configurePaints(requireContext(), animator) |
|
|
|
// TODO |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val muxer = MMediaMuxer() |
|
|
|
val muxer = MMediaMuxer() |
|
|
|
muxer.Init(requireActivity(), bitmap.width, bitmap.height, "hhVideo", "YES!") |
|
|
|
muxer.Init(requireActivity(), width.toInt(), height.toInt(), "hhVideo", "YES!") |
|
|
|
|
|
|
|
|
|
|
|
HandStep.createSteps(this.model.handHistory).forEach { step -> |
|
|
|
animator.frames(requireContext()) { bitmap -> |
|
|
|
|
|
|
|
|
|
|
|
step.frames(config, tc, requireContext()) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
val byteArray = bitmap.toByteArray() |
|
|
|
val byteArray = bitmap.toByteArray() |
|
|
|
muxer.AddFrame(byteArray) |
|
|
|
muxer.AddFrame(byteArray) |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
Timber.e("error = ${e.message}") |
|
|
|
Timber.e("error = ${e.message}") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|