Skip to content

Commit 2145d57

Browse files
committed
feat: hide keyboard and clear focus when the link name field loses focus
1 parent 7598a6d commit 2145d57

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/links/AddPublicLinkFragment.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import com.owncloud.android.domain.capabilities.model.OCCapability
3535
import com.owncloud.android.domain.links.model.OCLinkType
3636
import com.owncloud.android.domain.spaces.model.OCSpace
3737
import com.owncloud.android.extensions.collectLatestLifecycleFlow
38+
import com.owncloud.android.extensions.hideSoftKeyboard
3839
import com.owncloud.android.extensions.showErrorInSnackbar
3940
import com.owncloud.android.presentation.capabilities.CapabilityViewModel
4041
import com.owncloud.android.presentation.common.UIResult
@@ -190,6 +191,7 @@ class AddPublicLinkFragment: Fragment(), SetPasswordDialogFragment.SetPasswordLi
190191
}
191192

192193
private fun selectRadioButton(selectedRadioButton: RadioButton) {
194+
hideKeyboardAndClearFocus()
193195
binding.publicLinkPermissions.apply {
194196
canViewPublicLinkRadioButton.isChecked = false
195197
canEditPublicLinkRadioButton.isChecked = false
@@ -203,6 +205,7 @@ class AddPublicLinkFragment: Fragment(), SetPasswordDialogFragment.SetPasswordLi
203205

204206
private fun bindDatePickerDialog(expirationDate: String?) {
205207
binding.expirationDateLayout.expirationDateSwitch.setOnCheckedChangeListener { _, isChecked ->
208+
hideKeyboardAndClearFocus()
206209
if (isChecked) {
207210
openDatePickerDialog(expirationDate)
208211
} else {
@@ -249,14 +252,21 @@ class AddPublicLinkFragment: Fragment(), SetPasswordDialogFragment.SetPasswordLi
249252
}
250253

251254
private fun showPasswordDialog(password: String? = null) {
255+
binding.publicLinkNameEditText.clearFocus()
252256
val dialog = SetPasswordDialogFragment.newInstance(accountName, password, this)
253257
dialog.show(parentFragmentManager, DIALOG_SET_PASSWORD)
254258
}
255259

256260
private fun removePassword() {
261+
hideKeyboardAndClearFocus()
257262
spaceLinksViewModel.onPasswordSelected(null)
258263
}
259264

265+
private fun hideKeyboardAndClearFocus() {
266+
hideSoftKeyboard()
267+
binding.publicLinkNameEditText.clearFocus()
268+
}
269+
260270
companion object {
261271
private const val DIALOG_SET_PASSWORD = "DIALOG_SET_PASSWORD"
262272
private const val ARG_ACCOUNT_NAME = "ARG_ACCOUNT_NAME"

0 commit comments

Comments
 (0)