diff --git a/app/src/main/java/openfoodfacts/github/scrachx/openfood/fragments/AddProductIngredientsFragment.java b/app/src/main/java/openfoodfacts/github/scrachx/openfood/fragments/AddProductIngredientsFragment.java index 91a9592be365..477ad9ad6a52 100644 --- a/app/src/main/java/openfoodfacts/github/scrachx/openfood/fragments/AddProductIngredientsFragment.java +++ b/app/src/main/java/openfoodfacts/github/scrachx/openfood/fragments/AddProductIngredientsFragment.java @@ -5,8 +5,8 @@ import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceManager; -import android.text.TextUtils; import android.text.Editable; +import android.text.TextUtils; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; +import butterknife.OnTextChanged; import openfoodfacts.github.scrachx.openfood.R; import openfoodfacts.github.scrachx.openfood.databinding.FragmentAddProductIngredientsBinding; import openfoodfacts.github.scrachx.openfood.images.PhotoReceiver; @@ -289,7 +290,7 @@ public void onError(Exception ex) { } String ingredientsText = mOfflineSavedProduct.getIngredients(); if (!TextUtils.isEmpty(ingredientsText)) { - binding.ingredients.setText(ingredientsText); + binding.ingredientsList.setText(ingredientsText); } if (productDetails.get(OfflineSavedProduct.KEYS.PARAM_TRACES) != null) { List chipValues = Arrays.asList(productDetails.get(OfflineSavedProduct.KEYS.PARAM_TRACES).split("\\s*,\\s*")); @@ -406,7 +407,7 @@ public void getAllDetails(Map targetMap) { if (activity instanceof AddProductActivity) { String languageCode = ((AddProductActivity) activity).getProductLanguageForEdition(); String lc = (!languageCode.isEmpty()) ? languageCode : "en"; - targetMap.put(OfflineSavedProduct.KEYS.GET_PARAM_INGREDIENTS(lc), ingredients.getText().toString()); + targetMap.put(OfflineSavedProduct.KEYS.GET_PARAM_INGREDIENTS(lc), binding.ingredientsList.getText().toString()); List list = binding.traces.getChipValues(); String string = StringUtils.join(list, ","); targetMap.put(OfflineSavedProduct.KEYS.PARAM_TRACES.substring(4), string); diff --git a/app/src/main/java/openfoodfacts/github/scrachx/openfood/fragments/AddProductNutritionFactsFragment.java b/app/src/main/java/openfoodfacts/github/scrachx/openfood/fragments/AddProductNutritionFactsFragment.java index c5ee5e88e86e..688bcb70b3dc 100644 --- a/app/src/main/java/openfoodfacts/github/scrachx/openfood/fragments/AddProductNutritionFactsFragment.java +++ b/app/src/main/java/openfoodfacts/github/scrachx/openfood/fragments/AddProductNutritionFactsFragment.java @@ -152,7 +152,6 @@ public void afterTextChanged(Editable s) { }); binding.checkboxNoNutritionData.setOnCheckedChangeListener((buttonView, isChecked) -> onCheckedChanged(isChecked)); - photoReceiverHandler = new PhotoReceiverHandler(this); binding.btnAddANutrient.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_add_box_black_18dp, 0, 0, 0); Bundle b = getArguments(); @@ -332,7 +331,7 @@ private void preFillValuesFromOffline() { loadNutritionsImage(path); } if (productDetails.get(OfflineSavedProduct.KEYS.PARAM_NO_NUTRITION_DATA) != null) { - binding.checkboxNoNutritionDatanoNutritionData.setChecked(true); + binding.checkboxNoNutritionData.setChecked(true); binding.nutritionFactsLayout.setVisibility(View.GONE); } if (productDetails.get(OfflineSavedProduct.KEYS.PARAM_NUTRITION_DATA_PER) != null) { @@ -664,7 +663,8 @@ public void getDetails(Map targetMap) { } } if (EditTextUtils.isNotEmpty(binding.servingSize)) { - String servingSizeValue = EditTextUtils.content(binding.servingSize) + ObjectUtils.toString(this.servingSize.getAttachedSpinner().getSelectedItem().toString()); + String servingSizeValue = EditTextUtils.content(binding.servingSize) + ObjectUtils + .toString(binding.servingSize.getAttachedSpinner().getSelectedItem().toString()); if (product == null || !servingSizeValue.equals(product.getServingSize())) { targetMap.put(OfflineSavedProduct.KEYS.PARAM_SERVING_SIZE, servingSizeValue); } @@ -687,10 +687,6 @@ private boolean hasUnit(CustomValidatingEditTextView editTextView) { return !Nutriments.PH.equals(shortName) && !Nutriments.ALCOHOL.equals(shortName); } - private boolean isDataPer100() { - return binding.radioGroup.getCheckedRadioButtonId() == R.id.for100g_100ml; - } - /** * Add nutients to the map by from the text enetered into EditText * @@ -714,6 +710,7 @@ private float getReferenceValueInGram() { } return reference; } + /** * Add nutrients to the map by from the text entered into EditText, only if the value has been edited * @@ -790,7 +787,7 @@ private void addNutrientToMapIfUpdated(CustomValidatingEditTextView editTextView } private boolean isDataPer100() { - return radioGroup.getCheckedRadioButtonId() == R.id.for100g_100ml; + return binding.radioGroup.getCheckedRadioButtonId() == R.id.for100g_100ml; } void addNutrient() { diff --git a/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/ContinuousScanActivity.java b/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/ContinuousScanActivity.java index 8572f54f2c89..4de151411839 100644 --- a/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/ContinuousScanActivity.java +++ b/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/ContinuousScanActivity.java @@ -101,19 +101,13 @@ public class ContinuousScanActivity extends AppCompatActivity { private Product product; private ProductFragment productFragment; private SharedPreferences.Editor editor; - private BeepManager beepManager; - private String lastText; private SharedPreferences sp; - private boolean mFlash; private boolean mRing; private int peekLarge; private int peekSmall; private PopupMenu popup; - private Product product; - private ProductFragment productFragment; private boolean productShowing = false; private Runnable runnable; - private SharedPreferences sp; private SummaryProductPresenter summaryProductPresenter; private BarcodeCallback callback = new BarcodeCallback() { @Override @@ -457,11 +451,11 @@ public void onError(Exception ex) { binding.quickViewImageProgress.setVisibility(GONE); } - txtProductCallToAction.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); - txtProductCallToAction.setBackground(ContextCompat.getDrawable(ContinuousScanActivity.this, R.drawable.rounded_quick_view_text)); - txtProductCallToAction.setText(R.string.product_not_complete); - txtProductCallToAction.setVisibility(VISIBLE); - slideUpIndicator.setVisibility(GONE); + binding.txtProductCallToAction.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + binding.txtProductCallToAction.setBackground(ContextCompat.getDrawable(ContinuousScanActivity.this, R.drawable.rounded_quick_view_text)); + binding.txtProductCallToAction.setText(R.string.product_not_complete); + binding.txtProductCallToAction.setVisibility(VISIBLE); + binding.quickViewSlideUpIndicator.setVisibility(GONE); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } @@ -632,7 +626,7 @@ public void onStateChanged(@NonNull View bottomSheet, int newState) { bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } } - if (binding.searchByBarcode.getVisibility() == VISIBLE) { + if (binding.quickViewSearchByBarcode.getVisibility() == VISIBLE) { bottomSheetBehavior.setPeekHeight(peekSmall); bottomSheet.getLayoutParams().height = bottomSheetBehavior.getPeekHeight(); bottomSheet.requestLayout(); diff --git a/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/product/summary/SummaryProductFragment.java b/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/product/summary/SummaryProductFragment.java index 62c906b05ce8..ea9e129d20bf 100644 --- a/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/product/summary/SummaryProductFragment.java +++ b/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/product/summary/SummaryProductFragment.java @@ -812,10 +812,9 @@ private void loadPhoto(File photoFile) { public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); photoReceiverHandler.onActivityResult(this, requestCode, resultCode, data); - boolean shouldRefresh = (requestCode == EDIT_REQUEST_CODE && resultCode == Activity.RESULT_OK && data.getBooleanExtra(AddProductActivity.UPLOADED_TO_SERVER, false)); - if (ProductImageManagementActivity.isImageModified(requestCode, resultCode)) { - shouldRefresh = true; - } + boolean shouldRefresh = requestCode == EDIT_REQUEST_CODE && resultCode == Activity.RESULT_OK; + shouldRefresh = shouldRefresh || ProductImageManagementActivity.isImageModified(requestCode, resultCode); + if (shouldRefresh && getActivity() instanceof ProductActivity) { ((ProductActivity) getActivity()).onRefresh(); }