Skip to content

Commit

Permalink
Add view for palm oil
Browse files Browse the repository at this point in the history
  • Loading branch information
itchix committed Jun 20, 2015
1 parent 370e106 commit 8dc4607
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 98 deletions.
24 changes: 24 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions app/app.iml
Expand Up @@ -12,10 +12,12 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand All @@ -24,7 +26,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
<exclude-output />
Expand Down Expand Up @@ -103,10 +105,10 @@
<orderEntry type="library" exported="" name="appcompat-v7-22.1.1" level="project" />
<orderEntry type="library" exported="" name="core-1.7" level="project" />
<orderEntry type="library" exported="" name="jackson-annotations-2.5.0" level="project" />
<orderEntry type="library" exported="" name="androidasync-2.1.3" level="project" />
<orderEntry type="library" exported="" name="core-3.2.0" level="project" />
<orderEntry type="library" exported="" name="androidasync-2.1.6" level="project" />
<orderEntry type="library" exported="" name="jackson-core-2.5.0" level="project" />
<orderEntry type="library" exported="" name="ion-2.1.3" level="project" />
<orderEntry type="library" exported="" name="ion-2.1.6" level="project" />
<orderEntry type="library" exported="" name="sugar-1.3.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.1.1" level="project" />
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "openfoodfacts.github.scrachx.openfood"
minSdkVersion 15
targetSdkVersion 21
versionCode 2
versionName "0.1.1"
versionCode 3
versionName "0.1.2"
}
buildTypes {
release {
Expand Down

This file was deleted.

Expand Up @@ -18,7 +18,7 @@
*/
public class IngredientsProductFragment extends Fragment {

TextView ingredientProduct, substanceProduct, traceProduct, additiveProduct, palmOilProduct, mayBeFromPalmOilProduct;
TextView ingredientProduct, substanceProduct, traceProduct, additiveProduct;

@Nullable
@Override
Expand All @@ -29,8 +29,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
substanceProduct = (TextView) rootView.findViewById(R.id.textSubstanceProduct);
traceProduct = (TextView) rootView.findViewById(R.id.textTraceProduct);
additiveProduct = (TextView) rootView.findViewById(R.id.textAdditiveProduct);
palmOilProduct = (TextView) rootView.findViewById(R.id.textPalmOilProduct);
mayBeFromPalmOilProduct = (TextView) rootView.findViewById(R.id.textMayBeFromPalmOilProduct);

Intent intent = getActivity().getIntent();
State state = (State) intent.getExtras().getSerializable("state");
Expand All @@ -45,8 +43,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
}
traceProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtTraces) + "</b>" + ' ' + traces));
additiveProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtAdditives) + "</b>" + ' ' + state.getProduct().getAdditivesTags().toString().replace("[", "").replace("]","")));
palmOilProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtPalmOilProduct) + "</b>" + ' ' + state.getProduct().getIngredientsFromPalmOilTags().toString().replace("[","").replace("]","")));
mayBeFromPalmOilProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtMayBeFromPalmOilProduct) + "</b>" + ' ' + state.getProduct().getIngredientsThatMayBeFromPalmOilTags().toString().replace("[","").replace("]","")));

return rootView;
}
Expand Down
@@ -0,0 +1,56 @@
package openfoodfacts.github.scrachx.openfood.fragments;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import openfoodfacts.github.scrachx.openfood.R;
import openfoodfacts.github.scrachx.openfood.models.State;

/**
* Created by scotscriven on 09/05/15.
*/
public class PalmProductFragment extends Fragment {

private TextView palmOilProduct, mayBeFromPalmOilProduct;
private ImageView imageOkNo;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_palm_product,container,false);

palmOilProduct = (TextView) rootView.findViewById(R.id.textPalmOilProduct);
mayBeFromPalmOilProduct = (TextView) rootView.findViewById(R.id.textMayBeFromPalmOilProduct);
imageOkNo = (ImageView) rootView.findViewById(R.id.imageOkNo);

Intent intent = getActivity().getIntent();
State state = (State) intent.getExtras().getSerializable("state");

if(state.getProduct().getIngredientsFromPalmOilN() == 0 && state.getProduct().getIngredientsFromOrThatMayBeFromPalmOilN() == 0){
imageOkNo.setImageResource(R.drawable.ok);
palmOilProduct.setVisibility(View.VISIBLE);
palmOilProduct.setText(getString(R.string.txtPalm));
} else {
imageOkNo.setImageResource(R.drawable.no);
if(!state.getProduct().getIngredientsFromPalmOilTags().toString().replace("[", "").replace("]", "").isEmpty()) {
palmOilProduct.setVisibility(View.VISIBLE);
palmOilProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtPalmOilProduct) + "</b>" + ' ' + state.getProduct().getIngredientsFromPalmOilTags().toString().replace("[", "").replace("]", "")));
}
if(!state.getProduct().getIngredientsThatMayBeFromPalmOilTags().toString().replace("[", "").replace("]", "").isEmpty()) {
mayBeFromPalmOilProduct.setVisibility(View.VISIBLE);
mayBeFromPalmOilProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtMayBeFromPalmOilProduct) + "</b>" + ' ' + state.getProduct().getIngredientsThatMayBeFromPalmOilTags().toString().replace("[","").replace("]","")));
}
}


return rootView;
}
}
Expand Up @@ -10,16 +10,15 @@
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.ArrayList;
import openfoodfacts.github.scrachx.openfood.R;
import openfoodfacts.github.scrachx.openfood.fragments.CarefulFragment;
import openfoodfacts.github.scrachx.openfood.fragments.IngredientsProductFragment;
import openfoodfacts.github.scrachx.openfood.fragments.NutritionProductFragment;
import openfoodfacts.github.scrachx.openfood.fragments.PalmProductFragment;
import openfoodfacts.github.scrachx.openfood.fragments.SummaryProductFragment;
import openfoodfacts.github.scrachx.openfood.models.NavDrawerItem;
import openfoodfacts.github.scrachx.openfood.views.adapters.NavDrawerListAdapter;
Expand Down Expand Up @@ -70,8 +69,8 @@ protected void onCreate(Bundle savedInstanceState) {
navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
// Nutrition
navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
// Be careful
//navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
// Palm oil
navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
// Back to home
navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));

Expand Down Expand Up @@ -153,10 +152,10 @@ private void displayView(int position) {
case 2:
fragment = new NutritionProductFragment();
break;
/*case 3:
fragment = new CarefulFragment();
break;*/
case 3:
fragment = new PalmProductFragment();
break;
case 4:
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
this.finish();
Expand Down
Binary file added app/src/main/res/drawable-hdpi/ic_palm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_palm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_palm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/no.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ok.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_palm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions app/src/main/res/layout/fragment_careful.xml

This file was deleted.

24 changes: 0 additions & 24 deletions app/src/main/res/layout/fragment_ingredients_product.xml
Expand Up @@ -70,30 +70,6 @@
android:background="@drawable/textview_full"
android:id="@+id/textAdditiveProduct" />

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/font_normal"
android:layout_marginTop="@dimen/spacing_tiny"
android:layout_marginBottom="@dimen/spacing_tiny"
android:layout_marginLeft="@dimen/spacing_normal"
android:layout_marginRight="@dimen/spacing_normal"
android:padding="@dimen/spacing_small"
android:background="@drawable/textview_full"
android:id="@+id/textPalmOilProduct" />

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/font_normal"
android:layout_marginTop="@dimen/spacing_tiny"
android:layout_marginBottom="@dimen/spacing_tiny"
android:layout_marginLeft="@dimen/spacing_normal"
android:layout_marginRight="@dimen/spacing_normal"
android:padding="@dimen/spacing_small"
android:background="@drawable/textview_full"
android:id="@+id/textMayBeFromPalmOilProduct" />

</LinearLayout>

</ScrollView>
Expand Down
43 changes: 43 additions & 0 deletions app/src/main/res/layout/fragment_palm_product.xml
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageOkNo"
android:scaleType="fitXY"
android:padding="10dp"
android:layout_marginEnd="@dimen/spacing_normal"
android:layout_marginStart="@dimen/spacing_normal"
android:layout_gravity="center_horizontal" />

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/font_normal"
android:layout_marginTop="@dimen/spacing_tiny"
android:layout_marginBottom="@dimen/spacing_tiny"
android:layout_marginLeft="@dimen/spacing_normal"
android:layout_marginRight="@dimen/spacing_normal"
android:padding="@dimen/spacing_small"
android:background="@drawable/textview_full"
android:id="@+id/textPalmOilProduct"
android:visibility="gone"/>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/font_normal"
android:layout_marginTop="@dimen/spacing_tiny"
android:layout_marginBottom="@dimen/spacing_tiny"
android:layout_marginLeft="@dimen/spacing_normal"
android:layout_marginRight="@dimen/spacing_normal"
android:padding="@dimen/spacing_small"
android:background="@drawable/textview_full"
android:id="@+id/textMayBeFromPalmOilProduct"
android:visibility="gone"/>


</LinearLayout>
3 changes: 2 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Expand Up @@ -24,7 +24,7 @@
<item>Résumé</item>
<item>Ingrédients</item>
<item>Nutrition</item>
<item>Attention</item>
<item>Huile de palme</item>
<item>Retour menu</item>
</string-array>
<string name="alert_dialog_product_error_msg">Produit non trouvé, veuillez recommencer</string>
Expand Down Expand Up @@ -90,4 +90,5 @@
<string name="txtContentDialogUploading">Ne quittez pas durant l\'envoi...</string>
<string name="txtAllsent">Produits envoyés</string>
<string name="txtAbout">Les photos que vous envoyez sont publiées sous la licence libre Creative Commons Attribution et partage à l\'identitque.</string>
<string name="txtPalm">Le produit ne contient pas d\'huile de palme</string>
</resources>
27 changes: 3 additions & 24 deletions app/src/main/res/values/strings.xml
Expand Up @@ -33,7 +33,7 @@
<item>Summary</item>
<item>Ingredients</item>
<item>Nutrition</item>
<item>Be careful</item>
<item>Palm oil</item>
<item>Back to menu</item>
</string-array>

Expand All @@ -42,7 +42,7 @@
<item>@drawable/ic_summary_product</item>
<item>@drawable/ic_ingredient</item>
<item>@drawable/ic_nutrition</item>
<item>@drawable/ic_camera</item>
<item>@drawable/ic_palm</item>
<item>@drawable/ic_home</item>
</array>

Expand Down Expand Up @@ -111,6 +111,7 @@
<string name="txtContentDialogUploading">Please don\'t exit during the process...</string>
<string name="txtAbout">The pictures you send are published under the free licence Creative Commons Attribution and ShareAlike.</string>
<string name="txtAllsent">Products sent</string>
<string name="txtPalm">The product does not contain any palm oil</string>

<style name="DefaultButtonText">
<item name="android:layout_width">fill_parent</item>
Expand All @@ -126,26 +127,4 @@
<item name="android:shadowRadius">1</item>
</style>

<!-- <string-array name="countries_array_id">
<item>world</item>
<item>de</item>
<item>es</item>
<item>us</item>
<item>fr</item>
<item>lu</item>
<item>mc</item>
<item>uk</item>
</string-array>
<string-array name="countries_array">
<item>World</item>
<item>Allemagne</item>
<item>Espagne</item>
<item>États-Unis</item>
<item>France</item>
<item>Luxembourg</item>
<item>Monaco</item>
<item>Royaume-Uni</item>
</string-array> -->

</resources>

0 comments on commit 8dc4607

Please sign in to comment.