Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
app: Auto login is only allowed if Save Password is checked.
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Apr 21, 2024
1 parent 87fbb09 commit e61f874
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/src/main/kotlin/top/yukonga/update/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ class MainActivity : AppCompatActivity() {
val autoLoginCheckBox = createCheckBox(
R.string.auto_login, "auto_login", createLayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0f, 27)
)
savePasswordCheckBox.setOnCheckedChangeListener { _, isChecked ->
if (!isChecked) {
autoLoginCheckBox.isChecked = false
autoLoginCheckBox.isEnabled = false
} else {
autoLoginCheckBox.isEnabled = true
}
}
val linearLayout = LinearLayout(this).apply {
orientation = LinearLayout.HORIZONTAL
layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
Expand Down Expand Up @@ -580,7 +588,7 @@ class MainActivity : AppCompatActivity() {
}
}

fun createCheckBox(textId: Int, prefKey: String, layoutParams: LinearLayout.LayoutParams): MaterialCheckBox {
private fun createCheckBox(textId: Int, prefKey: String, layoutParams: LinearLayout.LayoutParams): MaterialCheckBox {
return MaterialCheckBox(this).apply {
isChecked = prefs.getString(prefKey, "") == "1"
setOnCheckedChangeListener { _, isChecked ->
Expand All @@ -592,7 +600,7 @@ class MainActivity : AppCompatActivity() {
}
}

fun createLayoutParams(width: Int, height: Int, weight: Float, marginEnd: Int): LinearLayout.LayoutParams {
private fun createLayoutParams(width: Int, height: Int, weight: Float, marginEnd: Int): LinearLayout.LayoutParams {
return LinearLayout.LayoutParams(width, height, weight).apply {
setMargins(23.dp, 0.dp, marginEnd.dp, 0.dp)
}
Expand Down

0 comments on commit e61f874

Please sign in to comment.