Commit 7bfcfe06 authored by MAQUIGNON Alexis's avatar MAQUIGNON Alexis
Browse files

premier commit

parent fc04f2a9
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
# Default ignored files
/shelf/
/workspace.xml
Wasted Food
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="1.8" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
/build
\ No newline at end of file
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.wastedfood"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
package com.example.wastedfood;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.wastedfood", appContext.getPackageName());
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wastedfood">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.WastedFood">
<activity android:name=".new_ingredient"></activity>
<activity android:name=".Recette_Informations" />
<activity android:name=".Recettes" />
<activity android:name=".MonFrigo" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package com.example.wastedfood;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
private Button Frigo;
private Button ConsulterRecette;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.Frigo = findViewById(R.id.Frigo);
Frigo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent otherActivity = new Intent(getApplicationContext(), MonFrigo.class);
startActivity(otherActivity);
finish();
}
});
this.ConsulterRecette = findViewById(R.id.ConsulterRecette);
ConsulterRecette.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent otherActivity = new Intent(getApplicationContext(), Recettes.class);
startActivity(otherActivity);
finish();
}
});
}
}
\ No newline at end of file
package com.example.wastedfood;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import com.example.wastedfood.new_ingredient;
import com.example.wastedfood.models.IngredientItem;
import java.util.Calendar;
import java.util.HashMap;
public class MonFrigo extends AppCompatActivity {
private Button ajouter_ingredient;
private ListView listView;
private String ingredient, date;
private HashMap<String,String> map;
private IngredientItem ingredientItem = new IngredientItem();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mon_frigo);
//list ingrédient
listView = findViewById(R.id.ingredient_list_view);
Bundle extras = getIntent().getExtras();
if(extras!=null)
{
ingredient = extras.getString("ingrédient");
date = extras.getString("date");
map = new HashMap<String,String>();
map.put("ingrédient",ingredient);
map.put("date",date);
ingredientItem.valeurs.add(map);
}
SimpleAdapter adapter = new SimpleAdapter(MonFrigo.this, ingredientItem.valeurs,R.layout.adapter_item_ingredient,
new String[]{"ingrédient", "date"}, new int[]{R.id.ingredient_name,R.id.ingredient_date});
listView.setAdapter(adapter);
/* if(date.compareTo(new_ingredient.getTodaysDate()) ==0 )
{
finish();
}*/
//bouton ajouter
this.ajouter_ingredient = findViewById(R.id.ajouter_ingredient);
ajouter_ingredient.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent otherActivity = new Intent(getApplicationContext(), new_ingredient.class);
startActivity(otherActivity);
finish();
}
});
}
}
\ No newline at end of file
package com.example.wastedfood;
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import com.example.wastedfood.adapters.RecetteItemAdapter;
import com.example.wastedfood.models.RecetteItem;
import java.util.List;
public class Recette_Informations extends AppCompatActivity {
TextView recetteName;
// int position;
// RecetteItem recetteItem = new RecetteItem();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recette__informations);
recetteName = findViewById(R.id.recette_name);
SimpleAdapter adapter = new SimpleAdapter(Recette_Informations.this, RecetteItem.valeurs, R.layout.activity_recette__informations,
new String[]{"ingrédient"}, new int[]{R.id.recette_name});
recetteName.setText((CharSequence) adapter);
}
}
\ No newline at end of file
package com.example.wastedfood;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import com.example.wastedfood.adapters.RecetteItemAdapter;
import com.example.wastedfood.models.RecetteItem;
import java.util.ArrayList;
import java.util.List;
public class Recettes extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recettes);
//list recettes
List<RecetteItem> recetteItemList = new ArrayList<>();
recetteItemList.add(new RecetteItem("Croque-Monsieur","croque","Facile"));
recetteItemList.add(new RecetteItem("Omelette","omelette","Facile"));
//get list view
ListView recettesListView = findViewById(R.id.recette_list_view);
recettesListView.setAdapter(new RecetteItemAdapter(this, recetteItemList));
}
}
\ No newline at end of file
package com.example.wastedfood.adapters;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.wastedfood.MonFrigo;
import com.example.wastedfood.R;
import com.example.wastedfood.Recette_Informations;
import com.example.wastedfood.models.RecetteItem;
import java.util.List;
public class RecetteItemAdapter extends BaseAdapter {
//attributs
private Context context;
private List<RecetteItem> recetteItemList;
private LayoutInflater inflater;
//Constructeur
public RecetteItemAdapter(Context context, List<RecetteItem> recetteItemList){
this.context = context;
this.recetteItemList = recetteItemList;
this.inflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return recetteItemList.size();
}
@Override
public RecetteItem getItem(int position) {
return recetteItemList.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = inflater.inflate(R.layout.adapter_item_recette, null);
//Information à propos de l'item
RecetteItem itemCourant = getItem(position);
String itemName = itemCourant.getName();
String tagPhoto = itemCourant.getTagPhoto();
String itemLevel = itemCourant.getLevel();
//get item icon view
ImageView itemIconView = convertView.findViewById(R.id.recette_icon);
String resourceName = "item_" + tagPhoto + "_icon";
int resId = context.getResources().getIdentifier(resourceName,"drawable", context.getPackageName());
itemIconView.setImageResource(resId);
//get item name view
TextView itemNameView = convertView.findViewById(R.id.recette_name);
itemNameView.setText(itemName);
//get item level view
TextView itemLevelView = convertView.findViewById(R.id.recette_dif);
itemLevelView.setText(itemLevel);
//click sur la recette pour avoir les infos
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent otherActivity = new Intent(context.getApplicationContext(), Recette_Informations.class);
context.startActivity(otherActivity);
}
});
return convertView;
}
}
package com.example.wastedfood.models;
import java.util.ArrayList;
import java.util.HashMap;
public class IngredientItem {
/*
// attribut
private String name;
private String date;
// Constructeur
public IngredientItem(String name, String date){
this.name = name;
this.date = date;
}
// methods
public String getName(){
return name;
}
public String getDate() {return date; }
*/
public static ArrayList<HashMap<String,String>> valeurs = new ArrayList<HashMap<String, String>>();
}
package com.example.wastedfood.models;
import java.util.ArrayList;
import java.util.HashMap;
public class RecetteItem {
// attribut
private String name;
private String tagPhoto;
private String level;
// Constructeur
public RecetteItem(String name, String tagPhoto, String level){
this.name = name;
this.tagPhoto = tagPhoto;
this.level = level;
}
// methods
public String getName(){
return name;
}
public String getTagPhoto() {return tagPhoto; }
public String getLevel() {
return level;
}
public static ArrayList<HashMap<String,String>> valeurs = new ArrayList<HashMap<String, String>>();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment