updated file export

This commit is contained in:
Trevor
2025-08-19 11:23:56 -05:00
parent 8f5d90a1c8
commit dc91987e88
2 changed files with 0 additions and 9 deletions
@@ -84,14 +84,12 @@ class PolycentricBackupActivity : AppCompatActivity() {
_buttonExportFile.visibility = View.INVISIBLE _buttonExportFile.visibility = View.INVISIBLE
lifecycleScope.launch { lifecycleScope.launch {
// Create export bundle first
val bundle = withContext(Dispatchers.IO) { createExportBundle() } val bundle = withContext(Dispatchers.IO) { createExportBundle() }
_exportBundle = bundle _exportBundle = bundle
Logger.i(TAG, "Export bundle created, length: ${bundle.length}") Logger.i(TAG, "Export bundle created, length: ${bundle.length}")
try { try {
val pair = withContext(Dispatchers.IO) { val pair = withContext(Dispatchers.IO) {
// Check if bundle is suitable for QR code
if (!isContentSuitableForQRCode(bundle)) { if (!isContentSuitableForQRCode(bundle)) {
throw Exception("Data too big for QR code generation") throw Exception("Data too big for QR code generation")
} }
@@ -110,7 +108,6 @@ class PolycentricBackupActivity : AppCompatActivity() {
_buttonShare.visibility = View.VISIBLE _buttonShare.visibility = View.VISIBLE
_buttonCopy.visibility = View.VISIBLE _buttonCopy.visibility = View.VISIBLE
// Add click listener to open QR code in fullscreen (only if QR generation succeeded)
_imageQR.setOnClickListener { _imageQR.setOnClickListener {
val intent = QRCodeFullscreenActivity.createIntent(this@PolycentricBackupActivity, _exportBundle) val intent = QRCodeFullscreenActivity.createIntent(this@PolycentricBackupActivity, _exportBundle)
startActivity(intent) startActivity(intent)
@@ -119,7 +116,6 @@ class PolycentricBackupActivity : AppCompatActivity() {
val byteSize = bundle.toByteArray(Charsets.UTF_8).size val byteSize = bundle.toByteArray(Charsets.UTF_8).size
Logger.e(TAG, "QR code generation failed. Bundle length: ${bundle.length} chars, ${byteSize} bytes, Error: ${e.message}", e) Logger.e(TAG, "QR code generation failed. Bundle length: ${bundle.length} chars, ${byteSize} bytes, Error: ${e.message}", e)
// Show file export button when QR code is too large
if (e.message?.contains("Data too big") == true) { if (e.message?.contains("Data too big") == true) {
_textQR.text = getString(R.string.qr_code_too_large_use_file_export) _textQR.text = getString(R.string.qr_code_too_large_use_file_export)
_buttonExportFile.visibility = View.VISIBLE _buttonExportFile.visibility = View.VISIBLE
@@ -161,7 +157,6 @@ class PolycentricBackupActivity : AppCompatActivity() {
} }
private fun generateQRCode(content: String, width: Int, height: Int): Bitmap { private fun generateQRCode(content: String, width: Int, height: Int): Bitmap {
// Check if content is too large for QR code generation
if (!isContentSuitableForQRCode(content)) { if (!isContentSuitableForQRCode(content)) {
throw Exception("Data too big for QR code generation") throw Exception("Data too big for QR code generation")
} }
@@ -47,7 +47,6 @@ class QRCodeFullscreenActivity : AppCompatActivity() {
// Generate QR code bitmap from text // Generate QR code bitmap from text
qrText?.let { text -> qrText?.let { text ->
try { try {
// Check if content is suitable for QR code
if (!isContentSuitableForQRCode(text)) { if (!isContentSuitableForQRCode(text)) {
throw Exception("Data too big for QR code generation") throw Exception("Data too big for QR code generation")
} }
@@ -63,7 +62,6 @@ class QRCodeFullscreenActivity : AppCompatActivity() {
} }
} }
// Set click listeners
buttonBack.setOnClickListener { buttonBack.setOnClickListener {
finish() finish()
} }
@@ -72,7 +70,6 @@ class QRCodeFullscreenActivity : AppCompatActivity() {
finish() finish()
} }
// Make the entire QR code area clickable to close
imageQR.setOnClickListener { imageQR.setOnClickListener {
finish() finish()
} }
@@ -84,7 +81,6 @@ class QRCodeFullscreenActivity : AppCompatActivity() {
} }
private fun generateQRCode(content: String, width: Int, height: Int): Bitmap { private fun generateQRCode(content: String, width: Int, height: Int): Bitmap {
// Check if content is too large for QR code generation
if (!isContentSuitableForQRCode(content)) { if (!isContentSuitableForQRCode(content)) {
throw Exception("Data too big for QR code generation") throw Exception("Data too big for QR code generation")
} }