Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if the user don't input http or https in the login url editbox, display appropriate message #36

Merged
merged 1 commit into from
Jan 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app/src/main/java/com/dokeraj/androtainer/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
etUrl.setOnFocusChangeListener { _, hasFocus ->
if (!hasFocus) {

when (Patterns.WEB_URL.matcher(etUrl.text.toString()).matches()) {
when (Patterns.WEB_URL.matcher(etUrl.text.toString()).matches() && (etUrl.text.toString().toLowerCase().startsWith("http") || etUrl.text.toString().toLowerCase().startsWith("https"))) {
true -> {
etUrl.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_web_link,
0,
Expand Down Expand Up @@ -151,15 +151,21 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
lgnBtn.setOnClickListener {
disableDrawerSwipe = true
btnLoginState.changeBtnState(false)
if (Patterns.WEB_URL.matcher(etUrl.text.toString()).matches()) {
if (Patterns.WEB_URL.matcher(etUrl.text.toString()).matches() && (etUrl.text.toString().toLowerCase().startsWith("http") || etUrl.text.toString().toLowerCase().startsWith("https"))) {
authenticate(etUrl.text.toString(),
etUser.text.toString(),
etPass.text.toString(), btnLoginState)
} else {

val errText = if (!etUrl.text.toString().toLowerCase().startsWith("http") && !etUrl.text.toString().toLowerCase().startsWith("https"))
"The URL must start with http:// or https://"
else
"Invalid URL!"

btnLoginState.changeBtnState(true)
globActivity.showGenericSnack(requireContext(),
requireView(),
"Invalid URL!",
errText,
R.color.white,
R.color.orange_warning)
}
Expand Down