Merge pull request #33 from kirmanak/version

Bump version to 0.1.6
This commit is contained in:
Kirill Kamakin
2022-04-04 21:25:39 +05:00
committed by GitHub
4 changed files with 31 additions and 23 deletions

View File

@@ -14,8 +14,8 @@ android {
applicationId "gq.kirmanak.mealient"
minSdk 23
targetSdk 31
versionCode 6
versionName "0.1.5"
versionCode 7
versionName "0.1.6"
}
signingConfigs {

View File

@@ -7,9 +7,11 @@ import android.view.WindowInsets
import android.widget.EditText
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.widget.doAfterTextChanged
import androidx.lifecycle.LifecycleCoroutineScope
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.textfield.TextInputLayout
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -21,6 +23,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import timber.log.Timber
@OptIn(ExperimentalCoroutinesApi::class)
@@ -83,25 +86,24 @@ fun <T> ChannelResult<T>.logErrors(methodName: String): ChannelResult<T> {
fun EditText.checkIfInputIsEmpty(
inputLayout: TextInputLayout,
lifecycleCoroutineScope: LifecycleCoroutineScope,
errorText: () -> String
lifecycleOwner: LifecycleOwner,
@StringRes stringId: Int,
trim: Boolean = true,
): String? {
Timber.v("checkIfInputIsEmpty() called with: input = $this, inputLayout = $inputLayout, errorText = $errorText")
val text = text?.toString()
val input = if (trim) text?.trim() else text
val text = input?.toString().orEmpty()
Timber.d("Input text is \"$text\"")
if (text.isNullOrEmpty()) {
inputLayout.error = errorText()
lifecycleCoroutineScope.launchWhenResumed {
return text.ifEmpty {
inputLayout.error = resources.getString(stringId)
lifecycleOwner.lifecycleScope.launch {
waitUntilNotEmpty()
inputLayout.error = null
}
return null
null
}
return text
}
suspend fun EditText.waitUntilNotEmpty() {
Timber.v("waitUntilNotEmpty() called with: input = $this")
textChangesFlow().filterNotNull().first { it.isNotEmpty() }
Timber.v("waitUntilNotEmpty() returned")
}

View File

@@ -39,13 +39,18 @@ class AuthenticationFragment : Fragment(R.layout.fragment_authentication) {
private fun onLoginClicked(): Unit = with(binding) {
Timber.v("onLoginClicked() called")
val email: String = emailInput.checkIfInputIsEmpty(emailInputLayout, lifecycleScope) {
getString(R.string.fragment_authentication_email_input_empty)
} ?: return
val email: String = emailInput.checkIfInputIsEmpty(
inputLayout = emailInputLayout,
lifecycleOwner = viewLifecycleOwner,
stringId = R.string.fragment_authentication_email_input_empty,
) ?: return
val pass: String = passwordInput.checkIfInputIsEmpty(passwordInputLayout, lifecycleScope) {
getString(R.string.fragment_authentication_password_input_empty)
} ?: return
val pass: String = passwordInput.checkIfInputIsEmpty(
inputLayout = passwordInputLayout,
lifecycleOwner = viewLifecycleOwner,
stringId = R.string.fragment_authentication_password_input_empty,
trim = false,
) ?: return
button.isClickable = false
viewLifecycleOwner.lifecycleScope.launch {

View File

@@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import by.kirich1409.viewbindingdelegate.viewBinding
import dagger.hilt.android.AndroidEntryPoint
@@ -29,9 +28,11 @@ class BaseURLFragment : Fragment(R.layout.fragment_base_url) {
private fun onProceedClick(view: View) {
Timber.v("onProceedClick() called with: view = $view")
val url = binding.urlInput.checkIfInputIsEmpty(binding.urlInputLayout, lifecycleScope) {
getString(R.string.fragment_baseurl_url_input_empty)
} ?: return
val url = binding.urlInput.checkIfInputIsEmpty(
inputLayout = binding.urlInputLayout,
lifecycleOwner = viewLifecycleOwner,
stringId = R.string.fragment_baseurl_url_input_empty,
) ?: return
viewModel.saveBaseUrl(url)
}