feat: added card view with full brightness, and center no cards text
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package ru.omni_devel.cards
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
|
||||
class ShowCardActivity : AppCompatActivity() {
|
||||
private lateinit var db: DbHelper
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContentView(R.layout.activity_show_card)
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||
insets
|
||||
}
|
||||
|
||||
db = DbHelper(this, null)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
setBrightness(1.0f)
|
||||
renderCard()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
|
||||
setBrightness(WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE)
|
||||
}
|
||||
|
||||
private fun renderCard() {
|
||||
val cardId = intent.getIntExtra("cardId", 0)
|
||||
|
||||
val cardInfo = db.getCard(cardId)
|
||||
|
||||
if (cardInfo == null) {
|
||||
Toast.makeText(this, "cardInfo is null", Toast.LENGTH_LONG).show()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
val cardCodeView: ImageView = findViewById(R.id.cardCodeView)
|
||||
|
||||
val code = generateCode(cardInfo.codeValue, cardInfo.codeType)
|
||||
|
||||
cardCodeView.setImageBitmap(code)
|
||||
}
|
||||
|
||||
private fun setBrightness(level: Float) {
|
||||
val params = window.attributes
|
||||
|
||||
params.screenBrightness = level
|
||||
|
||||
window.attributes = params
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user