Skip to content

Commit

Permalink
fix: select Specific Page when URL EditText is selected
Browse files Browse the repository at this point in the history
If the user selects the URL EditText we want to select Specific Page and select all text

We turn editable off and then on when another option is selected so we remove the focus on the EditText, which removes the keyboard and gives us the disabled look for the text entry
  • Loading branch information
mikescamell committed Sep 3, 2024
1 parent dd0e87c commit 6d47de2
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ShowOnAppLaunchActivity : DuckDuckGoActivity() {
setContentView(binding.root)
setupToolbar(binding.includeToolbar.toolbar)

binding.specificPageUrlInput.setSelectAllOnFocus(true)

configureUiEventHandlers()
observeViewModel()
}
Expand Down Expand Up @@ -78,6 +80,14 @@ class ShowOnAppLaunchActivity : DuckDuckGoActivity() {
binding.specificPageCheckListItem.setOnClickListener {
viewModel.onShowOnAppLaunchOptionChanged(SpecificPage(binding.specificPageUrlInput.text))
}

binding.specificPageUrlInput.addFocusChangedListener { _, hasFocus ->
if (hasFocus) {
viewModel.onShowOnAppLaunchOptionChanged(
SpecificPage(binding.specificPageUrlInput.text),
)
}
}
}

private fun observeViewModel() {
Expand All @@ -99,10 +109,6 @@ class ShowOnAppLaunchActivity : DuckDuckGoActivity() {
uncheckLastOpenedTabCheckListItem()
uncheckNewTabCheckListItem()
binding.specificPageCheckListItem.setChecked(true)
with(binding.specificPageUrlInput) {
isEditable = true
setSelectAllOnFocus(true)
}
}
}

Expand All @@ -122,5 +128,6 @@ class ShowOnAppLaunchActivity : DuckDuckGoActivity() {
private fun uncheckSpecificPageCheckListItem() {
binding.specificPageCheckListItem.setChecked(false)
binding.specificPageUrlInput.isEditable = false
binding.specificPageUrlInput.isEditable = true
}
}

0 comments on commit 6d47de2

Please sign in to comment.