mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] FNX2-15653:checks blanks name in homescreen shortcut name
This commit is contained in:
parent
20e0787404
commit
b9d20da423
@ -5,6 +5,7 @@
|
||||
package org.mozilla.fenix.shortcut
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -41,7 +42,7 @@ class CreateShortcutFragment : DialogFragment() {
|
||||
|
||||
cancel_button.setOnClickListener { dismiss() }
|
||||
add_button.setOnClickListener {
|
||||
val text = shortcut_text.text.toString()
|
||||
val text = shortcut_text.text.toString().trim()
|
||||
requireActivity().lifecycleScope.launch {
|
||||
requireComponents.useCases.webAppUseCases.addToHomescreen(text)
|
||||
}
|
||||
@ -57,10 +58,13 @@ class CreateShortcutFragment : DialogFragment() {
|
||||
}
|
||||
|
||||
private fun updateAddButtonEnabledState() {
|
||||
add_button.isEnabled = shortcut_text.text.isNotEmpty()
|
||||
add_button.alpha = if (shortcut_text.text.isNotEmpty()) ENABLED_ALPHA else DISABLED_ALPHA
|
||||
val text = shortcut_text.text
|
||||
add_button.isEnabled = isTextValid(text)
|
||||
add_button.alpha = if (isTextValid(text)) ENABLED_ALPHA else DISABLED_ALPHA
|
||||
}
|
||||
|
||||
private fun isTextValid(text: Editable) = text.isNotEmpty() && !text.isBlank()
|
||||
|
||||
companion object {
|
||||
private const val ENABLED_ALPHA = 1.0f
|
||||
private const val DISABLED_ALPHA = 0.4f
|
||||
|
Loading…
Reference in New Issue
Block a user