Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
meikpiep committed Dec 30, 2024
1 parent 9a9aed2 commit 16ca516
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
3 changes: 1 addition & 2 deletions gauguin-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ dependencies {

// debugImplementation(libs.thirdparty.leakcanary)

implementation("com.journeyapps:zxing-android-embedded:4.3.0") { isTransitive = false }
implementation("com.google.zxing:core:3.5.3")
implementation(libs.bundles.zxing)

testImplementation(libs.bundles.kotest)
testImplementation(libs.koin.test)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.zxing.BarcodeFormat
import com.journeyapps.barcodescanner.BarcodeEncoder
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.koin.android.ext.android.inject
import org.piepmeyer.gauguin.R
import org.piepmeyer.gauguin.databinding.ActivitySharegameBinding
import org.piepmeyer.gauguin.game.GameLifecycle
import org.piepmeyer.gauguin.game.Game
import org.piepmeyer.gauguin.game.save.SavedGrid
import org.piepmeyer.gauguin.ui.ActivityUtils
import java.io.ByteArrayOutputStream
import java.util.zip.GZIPOutputStream

class ShareGameActivity : AppCompatActivity() {
private val gameLifecycle: GameLifecycle by inject()
private val game: Game by inject()
private val activityUtils: ActivityUtils by inject()

public override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -23,9 +28,20 @@ class ShareGameActivity : AppCompatActivity() {

activityUtils.configureFullscreen(this)

val serializedGrid = Json.encodeToString(SavedGrid.fromGrid(game.grid))

println("${serializedGrid.length}")

val bos = ByteArrayOutputStream()
GZIPOutputStream(bos).bufferedWriter(Charsets.UTF_8).use { it.write(serializedGrid) }

val compressedGrid = String(bos.toByteArray())

println("${compressedGrid.length}")

try {
val barcodeEncoder = BarcodeEncoder()
val bitmap = barcodeEncoder.encodeBitmap("Test of QR code generation.", BarcodeFormat.QR_CODE, 400, 400)
val bitmap = barcodeEncoder.encodeBitmap(compressedGrid, BarcodeFormat.QR_CODE, 400, 400)
binding.qrCode.setImageBitmap(bitmap)
} catch (e: Exception) {
}
Expand Down
2 changes: 1 addition & 1 deletion gauguin-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="main_menu_item_save_game">Save</string>
<string name="main_menu_item_save_game_with_comment">Save with comment</string>
<string name="main_menu_item_share_game">Share via QR code</string>
<string name="main_menu_item_scan_game">Scan via QR code</string>
<string name="main_menu_item_scan_game">Scan QR code</string>
<string name="main_menu_item_restart_game">Restart Game</string>
<string name="main_menu_item_show_statistics">Statistics</string>
<string name="main_menu_item_open_settings">Settings</string>
Expand Down
4 changes: 4 additions & 0 deletions libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ thirdparty-vico = { group = "com.patrykandpatrick.vico", name = "views", version
thirdparty-androidplot = { group = "com.androidplot", name = "androidplot-core", version = "1.5.11" }
thirdparty-leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version = "2.14" }

zxing-embedded = { group = "com.journeyapps", name = "zxing-android-embedded", version = "4.3.0" }
zxing-core = { group = "com.google.zxing", name = "core", version = "3.5.3" }

[plugins]

android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
Expand All @@ -85,6 +88,7 @@ roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" }
logging = ["logging-kotlin", "logging-slf"]
kotest = ["kotest-runner", "kotest-assertions", "kotest-parametrizedtests", "kotest-koin"]
koin = ["koin-core", "koin-annotations", "koin-ksp-compiler"]
zxing = ["zxing-embedded", "zxing-core"]
androidx-test = ["androidx-test-junit-ktx", "androidx-test-rules", "androidx-test-runner"]
screenshotTests = ["androiduitestingutils-utils", "androiduitestingutils-robolectric", "roboelectric", "roborazzi", "roborazzi-junit", "junit-vintage-engine"]

0 comments on commit 16ca516

Please sign in to comment.