Skip to content

Commit

Permalink
Merge branch 'develop' into release/3.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
VaiTon committed Jan 10, 2021
2 parents 4594c29 + 872181c commit a966783
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 26 deletions.
Expand Up @@ -25,6 +25,7 @@ import android.view.MenuItem
import android.view.View
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContract
import androidx.core.content.ContextCompat
import androidx.core.content.edit
import com.afollestad.materialdialogs.MaterialDialog
import com.google.android.material.snackbar.BaseTransientBottomBar
Expand Down Expand Up @@ -122,15 +123,15 @@ class LoginActivity : BaseActivity() {
|| htmlNoParsed.contains("See you soon!")) {
Snackbar.make(binding.loginLinearlayout, R.string.errorLogin, BaseTransientBottomBar.LENGTH_LONG).show()
binding.passInput.setText("")
binding.txtInfoLogin.setTextColor(resources.getColor(R.color.red))
binding.txtInfoLogin.setTextColor(ContextCompat.getColor(this, R.color.red))
binding.txtInfoLogin.setText(R.string.txtInfoLoginNo)
snackbar.dismiss()
} else {
// store the user session id (user_session and user_id)
for (httpCookie in HttpCookie.parse(response.headers()["set-cookie"])) {
// Example format of set-cookie: session=user_session&S0MeR@nD0MSECRETk3Y&user_id&testuser; domain=.openfoodfacts.org; path=/
if (BuildConfig.HOST.contains(httpCookie.domain) && httpCookie.path == "/") {
val cookieValues = httpCookie.value.split("&").toTypedArray()
val cookieValues = httpCookie.value.split("&")
var i = 0
while (i < cookieValues.size) {
pref.edit { putString(cookieValues[i], cookieValues[++i]) }
Expand All @@ -144,7 +145,7 @@ class LoginActivity : BaseActivity() {
putString("user", login)
putString("pass", password)
}
binding.txtInfoLogin.setTextColor(resources.getColor(R.color.green_500))
binding.txtInfoLogin.setTextColor(ContextCompat.getColor(this, R.color.green_500))
binding.txtInfoLogin.setText(R.string.txtInfoLoginOk)
setResult(RESULT_OK)
finish()
Expand Down
Expand Up @@ -122,7 +122,6 @@ class CalculateDetailsActivity : BaseActivity() {
// Proteins
val proteins = nutriments[Nutriments.PROTEINS]
if (proteins != null) {
val modifier = nutriments.getModifier(Nutriments.PROTEINS)
nutrimentListItems.add(BoldNutrimentListItem(getString(R.string.nutrition_proteins),
proteins.getForAnyValue(weight, spinnerValue),
proteins.forServingInUnits,
Expand Down
Expand Up @@ -184,7 +184,7 @@ class ProductAttributeFragment : BottomSheetDialogFragment() {
var descriptionString: String? = null

val languageCode = LocaleHelper.getLanguage(OFFApplication.instance)
if (languageCode != null && map[languageCode] != null) {
if (map[languageCode] != null) {
descriptionString = map[languageCode]["value"].asText()
}

Expand Down
Expand Up @@ -511,12 +511,10 @@ class ContinuousScanActivity : AppCompatActivity() {

binding.quickViewTags.isNestedScrollingEnabled = false

window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
// The system bars are visible.
hideSystemUI()
}
}

// The system bars are visible.
hideSystemUI()

hintBarcodeDisp = Completable.timer(15, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.doOnComplete {
Expand Down
Expand Up @@ -16,7 +16,7 @@ fun getResourceId(field: ProductImageField) = when (field) {
else -> R.string.other_picture
}

fun Product.getImageStringKey(field: ProductImageField) = lang?.let { getImageStringKey(field, it) }
fun Product.getImageStringKey(field: ProductImageField) = getImageStringKey(field, lang)

fun getImageStringKey(field: ProductImageField, language: String) = "${field}_$language"

Expand Down
Expand Up @@ -11,6 +11,7 @@ import openfoodfacts.github.scrachx.openfood.network.ApiFields
import openfoodfacts.github.scrachx.openfood.network.ApiFields.Keys.lcProductNameKey
import openfoodfacts.github.scrachx.openfood.utils.LocaleHelper.getLanguage
import openfoodfacts.github.scrachx.openfood.utils.LocaleHelper.getLocale
import openfoodfacts.github.scrachx.openfood.utils.ProductStringConverter
import org.apache.commons.lang3.builder.ToStringBuilder
import org.apache.commons.lang3.builder.ToStringStyle
import java.io.Serializable
Expand Down
Expand Up @@ -15,7 +15,8 @@ class CustomValidatingEditTextView : AppCompatEditText {
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(attrs)
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr){

constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(attrs)
}

Expand Down Expand Up @@ -79,15 +80,13 @@ class CustomValidatingEditTextView : AppCompatEditText {

fun isValid() = !isError()

fun init( attrs:AttributeSet){
attrs?.let {
context.obtainStyledAttributes(it, R.styleable.CustomValidatingEditTextView).run {
textInputLayoutId = getResourceId(R.styleable.CustomValidatingEditTextView_parentTextInputLayout, NO_ID)
attachedUnitSpinnerId = getResourceId(R.styleable.CustomValidatingEditTextView_attachedUnitSpinner, NO_ID)
attachedModSpinnerId = getResourceId(R.styleable.CustomValidatingEditTextView_attachedModSpinner, NO_ID)
fieldName = getString(R.styleable.CustomValidatingEditTextView_fieldName)
recycle()
}
fun init(attrs: AttributeSet) {
context.obtainStyledAttributes(attrs, R.styleable.CustomValidatingEditTextView).run {
textInputLayoutId = getResourceId(R.styleable.CustomValidatingEditTextView_parentTextInputLayout, NO_ID)
attachedUnitSpinnerId = getResourceId(R.styleable.CustomValidatingEditTextView_attachedUnitSpinner, NO_ID)
attachedModSpinnerId = getResourceId(R.styleable.CustomValidatingEditTextView_attachedModSpinner, NO_ID)
fieldName = getString(R.styleable.CustomValidatingEditTextView_fieldName)
recycle()
}
}
}
Expand Up @@ -76,19 +76,19 @@ object UnitUtils {
return when {
servingSize.contains("ml", true) -> {
matcher.find()
var value = matcher.group(1).toFloat()
var value = matcher.group(1)!!.toFloat()
value *= OZ_PER_L / 1000
"${getRoundNumber(value)} oz"
}
servingSize.contains("cl", true) -> {
matcher.find()
var value = matcher.group(1).toFloat()
var value = matcher.group(1)!!.toFloat()
value *= OZ_PER_L / 100
"${getRoundNumber(value)} oz"
}
servingSize.contains("l", true) -> {
matcher.find()
var value = matcher.group(1).toFloat()
var value = matcher.group(1)!!.toFloat()
value *= OZ_PER_L
"${getRoundNumber(value)} oz"

Expand All @@ -111,7 +111,7 @@ object UnitUtils {
val regex = Pattern.compile("(\\d+(?:\\.\\d+)?)")
val matcher = regex.matcher(servingSize)
matcher.find()
var value = matcher.group(1).toFloat()
var value = matcher.group(1)!!.toFloat()
value /= OZ_PER_L
"$value l"
}
Expand Down

0 comments on commit a966783

Please sign in to comment.