Use Patterns.EMAIL_ADDRESS regex.

This commit is contained in:
Isira Seneviratne 2023-02-20 05:30:17 +05:30
parent a4e2496f58
commit bce6648a0a
2 changed files with 2 additions and 7 deletions

View File

@ -3,6 +3,7 @@ package com.github.libretube.ui.dialogs
import android.app.Dialog
import android.os.Bundle
import android.util.Log
import android.util.Patterns
import android.widget.Toast
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
@ -14,7 +15,6 @@ import com.github.libretube.api.obj.Token
import com.github.libretube.databinding.DialogLoginBinding
import com.github.libretube.extensions.TAG
import com.github.libretube.helpers.PreferenceHelper
import com.github.libretube.util.TextUtils
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.serialization.decodeFromString
import retrofit2.HttpException
@ -113,6 +113,6 @@ class LoginDialog(
}
private fun isEmail(text: String): Boolean {
return TextUtils.EMAIL_REGEX.toRegex().matches(text)
return Patterns.EMAIL_ADDRESS.toRegex().matches(text)
}
}

View File

@ -14,11 +14,6 @@ object TextUtils {
*/
const val SEPARATOR = ""
/**
* Regex to check for e-mails
*/
const val EMAIL_REGEX = "^[A-Za-z](.*)([@]{1})(.{1,})(\\.)(.{1,})"
/**
* Reserved characters by unix which can not be used for file name.
*/