package app.furmeet.events.brasilfurfest.schedule

import android.graphics.Point
import android.os.Bundle
import android.view.WindowManager
import androidmads.library.qrgenearator.QRGContents
import androidmads.library.qrgenearator.QRGEncoder
import com.adlerosn.brasilfurfest.R
import app.furmeet.events.brasilfurfest.TranslatableAppCompatActivity
import app.furmeet.events.brasilfurfest.helper.resourcesAliased
import kotlinx.android.synthetic.main.activity_asset_image_viewer.*
import kotlin.math.max


class QRCodeViewerActivity : TranslatableAppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
        window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
        setContentView(R.layout.activity_asset_image_viewer)
        resourcesAliased = this.resources
        resources.displayMetrics
        val display = windowManager.defaultDisplay
        val size = Point()
        display.getSize(size)
        val maxDimen = max(size.x, size.y)
        val data = intent.getStringExtra("data")
        val qr = QRGEncoder(data, null, QRGContents.Type.TEXT, maxDimen)
        val bitmap = qr.encodeAsBitmap()
        myZoomageView.setImageBitmap(bitmap)
    }
}