forked from shihaam/thijooree
redesign pin and pattern UI, add settings for changing lock and enable/disable biometrics and add button to lock app from any screen
This commit is contained in:
@@ -51,6 +51,10 @@ class LockActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun buildNumpad() {
|
||||
val dp = resources.displayMetrics.density
|
||||
val btnSize = (68 * dp).toInt()
|
||||
val btnMarginH = (10 * dp).toInt()
|
||||
val rowMarginV = (6 * dp).toInt()
|
||||
val rows = listOf(
|
||||
listOf("1", "2", "3"),
|
||||
listOf("4", "5", "6"),
|
||||
@@ -60,9 +64,11 @@ class LockActivity : AppCompatActivity() {
|
||||
rows.forEach { keys ->
|
||||
val row = LinearLayout(this).apply {
|
||||
orientation = LinearLayout.HORIZONTAL
|
||||
gravity = android.view.Gravity.CENTER
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f
|
||||
)
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).also { it.setMargins(0, rowMarginV, 0, rowMarginV) }
|
||||
}
|
||||
keys.forEach { key ->
|
||||
val style = if (key == "✓")
|
||||
@@ -71,10 +77,12 @@ class LockActivity : AppCompatActivity() {
|
||||
com.google.android.material.R.attr.materialButtonOutlinedStyle
|
||||
val btn = MaterialButton(this, null, style).apply {
|
||||
text = key
|
||||
textSize = 20f
|
||||
textSize = 24f
|
||||
insetTop = 0; insetBottom = 0
|
||||
layoutParams = LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)
|
||||
.also { it.setMargins(4, 4, 4, 4) }
|
||||
minimumWidth = 0; minimumHeight = 0
|
||||
cornerRadius = btnSize / 2
|
||||
layoutParams = LinearLayout.LayoutParams(btnSize, btnSize)
|
||||
.also { it.setMargins(btnMarginH, 0, btnMarginH, 0) }
|
||||
}
|
||||
btn.setOnClickListener { handleKey(key) }
|
||||
row.addView(btn)
|
||||
|
||||
Reference in New Issue
Block a user