Commit b8e00f52fadb39fcdd6542994dda75130f935663

Authored by martin.rohmer
0 parents

mise à disposition du projet

Showing 62 changed files with 2885 additions and 0 deletions   Show diff stats
app-release.apk 0 → 100644
No preview for this file type
partieAndroid/AndroidManifest.xml 0 → 100644
  1 +++ a/partieAndroid/AndroidManifest.xml
... ... @@ -0,0 +1,43 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3 + package="com.example.martin.projetv5"
  4 + android:versionCode="1">
  5 +
  6 + <uses-permission android:name="android.permission.VIBRATE" />
  7 + <uses-permission android:name="android.permission.WAKE_LOCK" />
  8 + <uses-permission android:name="android.permission.INTERNET" />
  9 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  10 + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  11 + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
  12 +
  13 + <application
  14 + android:allowBackup="true"
  15 + android:icon="@drawable/pill"
  16 + android:label="@string/app_name"
  17 + android:supportsRtl="true"
  18 + android:theme="@style/AppTheme">
  19 + <activity android:name=".MainActivity">
  20 + <intent-filter>
  21 + <action android:name="android.intent.action.MAIN" />
  22 +
  23 + <category android:name="android.intent.category.LAUNCHER" />
  24 + </intent-filter>
  25 + </activity>
  26 + <activity android:name=".HistoriqueActivity" />
  27 + <activity android:name=".GestionActivity" />
  28 + <activity android:name=".AjoutMedocActivity"/>
  29 + <activity android:name=".ModifMedocActivity"/>
  30 +
  31 + <receiver android:process=":remote" android:name=".Alarm"></receiver>
  32 + <receiver android:name=".AutoStart">
  33 + <intent-filter>
  34 + <action android:name="android.intent.action.BOOT_COMPLETED"></action>
  35 + </intent-filter>
  36 + </receiver>
  37 +
  38 + <service android:name=".AlarmeService" android:enabled="true" android:stopWithTask="true"></service>
  39 + <service android:name=".ServiceInitAlarme" android:enabled="true" android:process=":service_init_alarme"/>
  40 +
  41 + </application>
  42 +
  43 +</manifest>
0 44 \ No newline at end of file
... ...
partieAndroid/codesJava/AjoutMedocActivity.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/AjoutMedocActivity.java
... ... @@ -0,0 +1,96 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.Intent;
  4 +import android.os.Bundle;
  5 +import android.support.v7.app.AppCompatActivity;
  6 +import android.view.View;
  7 +import android.widget.ArrayAdapter;
  8 +import android.widget.AutoCompleteTextView;
  9 +import android.widget.Toast;
  10 +
  11 +import java.util.ArrayList;
  12 +
  13 +/**
  14 + * Created by martin on 28/02/2017.
  15 + */
  16 +
  17 +public class AjoutMedocActivity extends AppCompatActivity {
  18 +
  19 + StringBDD eventBDD = null;
  20 + ArrayList<String> arrayList = new ArrayList<>();
  21 + AutoCompleteTextView editNom = null;
  22 +
  23 +
  24 + public void onClickAjout(View view){
  25 + editNom = (AutoCompleteTextView) findViewById(R.id.textNom);
  26 + String s1 = editNom.getText().toString();
  27 +
  28 + // on regarde si le nom rentré existe
  29 + boolean existe = false;
  30 + int w=1;
  31 + while(w <= eventBDD.getIndiceMaxMedoc() && !existe) {
  32 + Medicament m = eventBDD.getMedocWithId(w);
  33 + if (m.getNom1().equals(s1)) existe = true;
  34 + w++;
  35 + }
  36 +
  37 + if(existe) {
  38 + Medicament m = eventBDD.getMedocWithNom1(s1);
  39 +
  40 + // s'il existe on regarde ensuite si ce medicament n'est pas déjà en train d'être pris
  41 + boolean ok = true;
  42 + int x=1;
  43 + while(x <= eventBDD.getIndiceMaxPrise() && ok){
  44 + Prise2 p = eventBDD.getPriseWithId(x);
  45 + if(p.getIdMedoc().equals(m.getIdM()))ok = false;
  46 + x++;
  47 + }
  48 +
  49 + if(ok) {
  50 + // si tout est bon, on poursuit
  51 + Intent i = new Intent(this, ModifMedocActivity.class);
  52 + boolean nouveau = true;
  53 + i.putExtra("id", m.getIdM());
  54 + i.putExtra("new", nouveau);
  55 + startActivity(i);
  56 + }
  57 + else Toast.makeText(this,R.string.ajout3,Toast.LENGTH_LONG).show();
  58 + }
  59 + else Toast.makeText(this,R.string.ajout2,Toast.LENGTH_LONG).show();
  60 + }
  61 +
  62 + void recupNom1Medoc(ArrayList<String> aList){
  63 + for(int w=0; w<eventBDD.getIndiceMaxMedoc(); w++){
  64 + String s = eventBDD.getMedocWithId(w+1).getNom1();
  65 + aList.add(w,s);
  66 + }
  67 + }
  68 +
  69 + @Override
  70 + protected void onCreate(Bundle savedInstanceState) {
  71 + super.onCreate(savedInstanceState);
  72 + setContentView(R.layout.ajout_layout);
  73 +
  74 + eventBDD = new StringBDD(this);
  75 + eventBDD.open();
  76 + }
  77 +
  78 + @Override
  79 + protected void onResume() {
  80 + eventBDD.open();
  81 + super.onResume();
  82 +
  83 + editNom = (AutoCompleteTextView) findViewById(R.id.textNom);
  84 + recupNom1Medoc(arrayList);
  85 + ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, arrayList);
  86 + editNom.setAdapter(adapter);
  87 + editNom.setThreshold(0);
  88 + }
  89 +
  90 + @Override
  91 + protected void onPause() {
  92 + eventBDD.close();
  93 + super.onPause();
  94 + arrayList.clear();
  95 + }
  96 +}
... ...
partieAndroid/codesJava/Alarm.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/Alarm.java
... ... @@ -0,0 +1,55 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.app.AlarmManager;
  4 +import android.app.PendingIntent;
  5 +import android.content.BroadcastReceiver;
  6 +import android.content.Context;
  7 +import android.content.Intent;
  8 +import android.os.PowerManager;
  9 +import android.util.Log;
  10 +
  11 +import java.util.Calendar;
  12 +
  13 +/**
  14 + * Created by martin on 06/05/2017.
  15 + */
  16 +
  17 +
  18 +public class Alarm extends BroadcastReceiver
  19 +{
  20 +
  21 + @Override
  22 + public void onReceive(Context context, Intent intent)
  23 + {
  24 + PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
  25 + PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "");
  26 + wl.acquire();
  27 + Intent i = new Intent(context,AlarmeService.class);
  28 + context.startService(i);
  29 + wl.release();
  30 + }
  31 +
  32 + public void setAlarm(Context context, String heure)
  33 + {
  34 + String[] s = heure.split("h");
  35 + Calendar calendar = Calendar.getInstance();
  36 + calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(s[0]));
  37 + calendar.set(Calendar.MINUTE, Integer.parseInt(s[1]));
  38 + long when = calendar.getTimeInMillis();
  39 +
  40 + if(when < System.currentTimeMillis()) when += 24*60*60000;
  41 +
  42 + AlarmManager am =( AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  43 + Intent i = new Intent(context, Alarm.class);
  44 + PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
  45 + am.set(AlarmManager.RTC_WAKEUP, when, pi);
  46 + }
  47 +
  48 + public void cancelAlarm(Context context)
  49 + {
  50 + Intent intent = new Intent(context, Alarm.class);
  51 + PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0);
  52 + AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
  53 + alarmManager.cancel(sender);
  54 + }
  55 +}
0 56 \ No newline at end of file
... ...
partieAndroid/codesJava/AlarmeService.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/AlarmeService.java
... ... @@ -0,0 +1,57 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.app.IntentService;
  4 +import android.app.Notification;
  5 +import android.app.NotificationManager;
  6 +import android.app.PendingIntent;
  7 +import android.app.TaskStackBuilder;
  8 +import android.content.Context;
  9 +import android.content.Intent;
  10 +import android.os.Vibrator;
  11 +
  12 +import static android.app.Notification.FLAG_AUTO_CANCEL;
  13 +
  14 +/**
  15 + * Created by martin on 15/03/2017.
  16 + */
  17 +
  18 +public class AlarmeService extends IntentService {
  19 + private final static String TAG ="IntentServiceExample";
  20 + public int ID_NOTIFICATION = 0;
  21 +
  22 + public AlarmeService(){
  23 + super(TAG);
  24 + }
  25 +
  26 + @Override
  27 + protected void onHandleIntent(Intent intent){
  28 + int icon = R.drawable.pill;
  29 + long when = System.currentTimeMillis();
  30 +
  31 + Vibrator vib = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
  32 + long pattern[] = {0,400,200,400};
  33 + vib.vibrate(pattern,-1);
  34 + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  35 + PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(),0,intent,0);
  36 +
  37 + Notification.Builder builder = new Notification.Builder(getApplicationContext())
  38 + .setWhen(when)
  39 + .setTicker(getString(R.string.notif1))
  40 + .setSmallIcon(icon)
  41 + .setContentTitle("Tech' your pill")
  42 + .setContentText(getString(R.string.notif1))
  43 + .setContentIntent(contentIntent);
  44 +
  45 + Intent resultIntent = new Intent(this,MainActivity.class);
  46 +
  47 + TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
  48 + stackBuilder.addNextIntent(intent);
  49 + PendingIntent resultPendingIntent = PendingIntent.getActivity(this,0,resultIntent,PendingIntent.FLAG_UPDATE_CURRENT);
  50 + builder.setContentIntent(resultPendingIntent);
  51 +
  52 + NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  53 + Notification notif = builder.build();
  54 + notif.flags = FLAG_AUTO_CANCEL;
  55 + manager.notify(ID_NOTIFICATION,notif);
  56 + }
  57 +}
... ...
partieAndroid/codesJava/AutoStart.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/AutoStart.java
... ... @@ -0,0 +1,28 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.BroadcastReceiver;
  4 +import android.content.Context;
  5 +import android.content.Intent;
  6 +
  7 +/**
  8 + * Created by martin on 06/05/2017.
  9 + */
  10 +
  11 +public class AutoStart extends BroadcastReceiver
  12 +{
  13 + Alarm alarm = new Alarm();
  14 + @Override
  15 + public void onReceive(Context context, Intent intent)
  16 + {
  17 + if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))
  18 + {
  19 + StringBDD eventBDD = new StringBDD(context);
  20 + eventBDD.open();
  21 + for(int i = 0; i<eventBDD.getIndiceMaxPrise(); i++){
  22 + Prise2 p = eventBDD.getPriseWithId(i+1);
  23 + alarm.setAlarm(context,p.getHeure());
  24 + }
  25 + eventBDD.close();
  26 + }
  27 + }
  28 +}
0 29 \ No newline at end of file
... ...
partieAndroid/codesJava/Event.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/Event.java
... ... @@ -0,0 +1,45 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +/**
  4 + * Created by martin on 21/02/2017.
  5 + */
  6 +
  7 +public class Event {
  8 + Integer id;
  9 + String date;
  10 + String heure;
  11 + String evenement;
  12 +
  13 + public Event(Integer i,String d, String h, String ev){
  14 + id = i;
  15 + date = d;
  16 + heure = h;
  17 + evenement = ev;
  18 + }
  19 +
  20 + public void setId(Integer i){
  21 + id = i;
  22 + }
  23 + public void setDate(String d){
  24 + date = d;
  25 + }
  26 + public void setHeure(String h) {
  27 + heure = h;
  28 + }
  29 + public void setEvenement(String ev){
  30 + evenement = ev;
  31 + }
  32 +
  33 + public Integer getId(){
  34 + return id;
  35 + }
  36 + public String getDate(){
  37 + return date;
  38 + }
  39 + public String getHeure(){
  40 + return heure;
  41 + }
  42 + public String getEvenement(){
  43 + return evenement;
  44 + }
  45 +}
... ...
partieAndroid/codesJava/EventAdapter.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/EventAdapter.java
... ... @@ -0,0 +1,68 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.Context;
  4 +import android.view.LayoutInflater;
  5 +import android.view.View;
  6 +import android.view.ViewGroup;
  7 +import android.widget.BaseAdapter;
  8 +import android.widget.LinearLayout;
  9 +import android.widget.TextView;
  10 +
  11 +import java.util.ArrayList;
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * Created by martin on 21/02/2017.
  16 + */
  17 +
  18 +public class EventAdapter extends BaseAdapter {
  19 + public List<Event> mList;
  20 + public Context mContext;
  21 + public LayoutInflater mInflater;
  22 +
  23 + public EventAdapter(Context context, List<Event> aList) {
  24 + mContext = context;
  25 + mList = aList;
  26 + mInflater = LayoutInflater.from(mContext);
  27 + }
  28 +
  29 + public int getCount() {
  30 + return mList.size();
  31 + }
  32 +
  33 + public Object getItem(int position) {
  34 + return mList.get(position);
  35 + }
  36 +
  37 + public long getItemId(int position) {
  38 + return position;
  39 + }
  40 +
  41 + public View getView(int position, View convertView, ViewGroup parent) {
  42 + LinearLayout layoutItem;
  43 +
  44 + if (convertView == null) {
  45 + layoutItem = (LinearLayout) mInflater.inflate(R.layout.event, parent, false);
  46 + } else {
  47 + layoutItem = (LinearLayout) convertView;
  48 + }
  49 +
  50 + TextView date = (TextView) layoutItem.findViewById(R.id.date);
  51 + TextView event = (TextView) layoutItem.findViewById(R.id.event);
  52 +
  53 + date.setText(mList.get(position).getDate());
  54 + event.setText(mList.get(position).getEvenement());
  55 +
  56 + return layoutItem;
  57 + }
  58 +
  59 + public interface EventAdapterListener {
  60 + void onClickButton(Event item, int position);
  61 + }
  62 +
  63 + private ArrayList<EventAdapterListener> mListListener = new ArrayList<EventAdapterListener>();
  64 +
  65 + public void addListener(EventAdapterListener aListener) {
  66 + mListListener.add(aListener);
  67 + }
  68 +}
0 69 \ No newline at end of file
... ...
partieAndroid/codesJava/GestionActivity.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/GestionActivity.java
... ... @@ -0,0 +1,109 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.Intent;
  4 +import android.os.Bundle;
  5 +import android.support.v7.app.AppCompatActivity;
  6 +import android.view.View;
  7 +import android.widget.ListView;
  8 +import android.widget.TextView;
  9 +
  10 +import java.util.ArrayList;
  11 +
  12 +/**
  13 + * Created by martin on 28/02/2017.
  14 + */
  15 +
  16 +public class GestionActivity extends AppCompatActivity implements MedocAdapterMenu.MedocAdapterListener {
  17 +
  18 + ArrayList<Medicament> listMedocs = new ArrayList<>();
  19 + MedocAdapterMenu adapter = null;
  20 + ListView list = null;
  21 + StringBDD eventBDD = null;
  22 +
  23 + void addElementList(Medicament m, ArrayList<Medicament> listM){
  24 + listM.add(m);
  25 + adapter.notifyDataSetChanged();
  26 + }
  27 +
  28 + void supList(ArrayList<Medicament> listM){
  29 + listM.clear();
  30 + adapter.notifyDataSetChanged();
  31 + }
  32 +
  33 + public void onClickAjoutMedoc(View view){
  34 + Intent i = new Intent(this, AjoutMedocActivity.class);
  35 + startActivity(i);
  36 + }
  37 +
  38 + public void gestionList(){
  39 + boolean present = false;
  40 + for(int w=0; w<eventBDD.getIndiceMaxMedoc(); w++){
  41 + boolean ok = false;
  42 + Medicament m = eventBDD.getMedocWithId(w+1);
  43 + int x=1;
  44 +
  45 + while(x <= eventBDD.getIndiceMaxPrise() && !ok){
  46 + Prise2 p = eventBDD.getPriseWithId(x);
  47 + if (p != null) {
  48 + if (p.getIdMedoc().equals(m.getIdM())) {
  49 + ok = true;
  50 + present = true;
  51 + }
  52 + }
  53 + x++;
  54 + }
  55 +
  56 + if(ok) addElementList(m,listMedocs);
  57 + }
  58 + if(!present){
  59 + TextView textView = (TextView) findViewById(R.id.aucunMedoc);
  60 + textView.setText(R.string.gestion2);
  61 + }
  62 + else{
  63 + TextView textView = (TextView) findViewById(R.id.aucunMedoc);
  64 + textView.setText("");
  65 + }
  66 + }
  67 +
  68 + @Override
  69 + protected void onCreate(Bundle savedInstanceState) {
  70 + super.onCreate(savedInstanceState);
  71 + setContentView(R.layout.gestion_layout);
  72 +
  73 + eventBDD = new StringBDD(this);
  74 + eventBDD.open();
  75 + }
  76 +
  77 + @Override
  78 + protected void onResume() {
  79 + eventBDD.open();
  80 + super.onResume();
  81 +
  82 + adapter = new MedocAdapterMenu(this,listMedocs);
  83 + adapter.addListener(this);
  84 + list = (ListView)findViewById(R.id.listMedoc);
  85 + list.setAdapter(adapter);
  86 +
  87 + gestionList();
  88 + }
  89 +
  90 + @Override
  91 + protected void onPause() {
  92 + super.onPause();
  93 + eventBDD.close();
  94 +
  95 + adapter = new MedocAdapterMenu(this,listMedocs);
  96 + adapter.addListener(this);
  97 + list = (ListView)findViewById(R.id.listMedoc);
  98 + list.setAdapter(adapter);
  99 +
  100 + supList(listMedocs);
  101 + }
  102 +
  103 + @Override
  104 + public void onClickButton(Medicament item, int position) {
  105 + Intent i = new Intent(this, ModifMedocActivity.class);
  106 + i.putExtra("id",item.getIdM());
  107 + startActivity(i);
  108 + }
  109 +}
... ...
partieAndroid/codesJava/HistoriqueActivity.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/HistoriqueActivity.java
... ... @@ -0,0 +1,64 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.os.Bundle;
  4 +import android.support.v7.app.AppCompatActivity;
  5 +import android.widget.ListView;
  6 +
  7 +import java.util.ArrayList;
  8 +
  9 +/**
  10 + * Created by martin on 18/02/2017.
  11 + */
  12 +
  13 +public class HistoriqueActivity extends AppCompatActivity implements EventAdapter.EventAdapterListener {
  14 +
  15 + ArrayList<Event> listEvents = new ArrayList<>();
  16 + EventAdapter adapter = null;
  17 + ListView list = null;
  18 +
  19 + Event[] tabEvents = null;
  20 +
  21 + StringBDD eventBDD = null;
  22 +
  23 + void addEventList(Event ev, ArrayList<Event> listP){
  24 + listP.add(ev);
  25 + adapter.notifyDataSetChanged();
  26 + }
  27 +
  28 + public void onCreate(Bundle savedInstanceState) {
  29 + super.onCreate(savedInstanceState);
  30 + setContentView(R.layout.historique_layout);
  31 +
  32 + adapter = new EventAdapter(this,listEvents);
  33 + adapter.addListener(this);
  34 + list = (ListView)findViewById(R.id.list2);
  35 + list.setAdapter(adapter);
  36 +
  37 + eventBDD = new StringBDD(this);
  38 + eventBDD.open();
  39 + int indMax = eventBDD.getIndiceMaxEvent();
  40 + tabEvents = new Event[indMax];
  41 +
  42 + for(int j=0; j<indMax; j++){
  43 + Event ev = eventBDD.getEventWithId(indMax-j);
  44 + addEventList(ev,listEvents);
  45 + }
  46 + }
  47 +
  48 + @Override
  49 + protected void onResume() {
  50 + eventBDD.open();
  51 + super.onResume();
  52 + }
  53 +
  54 + @Override
  55 + protected void onPause() {
  56 + eventBDD.close();
  57 + super.onPause();
  58 + }
  59 +
  60 + @Override
  61 + public void onClickButton(Event item, int position) {}
  62 +
  63 +
  64 +}
... ...
partieAndroid/codesJava/MainActivity.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/MainActivity.java
... ... @@ -0,0 +1,460 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.Context;
  4 +import android.content.DialogInterface;
  5 +import android.content.Intent;
  6 +import android.os.AsyncTask;
  7 +import android.os.Bundle;
  8 +import android.os.Environment;
  9 +import android.support.v7.app.AlertDialog;
  10 +import android.support.v7.app.AppCompatActivity;
  11 +import android.view.Gravity;
  12 +import android.view.View;
  13 +import android.view.Window;
  14 +import android.widget.ImageButton;
  15 +import android.widget.ListView;
  16 +import android.widget.TextView;
  17 +import android.widget.Toast;
  18 +
  19 +import java.io.BufferedReader;
  20 +import java.io.File;
  21 +import java.io.FileOutputStream;
  22 +import java.io.IOException;
  23 +import java.io.InputStream;
  24 +import java.io.InputStreamReader;
  25 +import java.net.HttpURLConnection;
  26 +import java.net.MalformedURLException;
  27 +import java.net.URL;
  28 +import java.text.SimpleDateFormat;
  29 +import java.util.ArrayList;
  30 +import java.util.Calendar;
  31 +import java.util.Date;
  32 +
  33 +public class MainActivity extends AppCompatActivity implements PriseAdapterMenu.PriseAdapterListener {
  34 +
  35 + ArrayList<Prise2> listPrises = new ArrayList<>();
  36 + PriseAdapterMenu adapter = null;
  37 + ListView list = null;
  38 +
  39 + String res = "";
  40 +
  41 + StringBDD eventBDD = null;
  42 +
  43 + String filepath=null;
  44 + boolean fini;
  45 +
  46 + public void gestionHeure(){
  47 + supList(listPrises);
  48 +
  49 + long now = System.currentTimeMillis();
  50 + int cpt = 0;
  51 +
  52 + for(int w=0; w<eventBDD.getIndiceMaxPrise(); w++){
  53 + Prise2 p = eventBDD.getPriseWithId(w+1);
  54 +
  55 + if (p != null) {
  56 + String[] decoupeDate = p.getHeure().split("h");
  57 + Calendar h_prise = Calendar.getInstance();
  58 + h_prise.set(Calendar.HOUR_OF_DAY, Integer.parseInt(decoupeDate[0]));
  59 + h_prise.set(Calendar.MINUTE, Integer.parseInt(decoupeDate[1]));
  60 + long valeurDate = h_prise.getTimeInMillis();
  61 +
  62 + Calendar h2 = Calendar.getInstance();
  63 + h2.set(Calendar.HOUR_OF_DAY, 2);
  64 + h2.set(Calendar.MINUTE, 0);
  65 + long valeur2h = h2.getTimeInMillis();
  66 +
  67 + if(now < valeur2h && valeurDate >= valeur2h+3600000*20){
  68 + valeurDate -= 3600000*24;
  69 + }
  70 + if((now >= valeurDate && now <= valeurDate+3600000*2 && p.getEffectuee().equals("false"))) {
  71 + addElementList(p, listPrises);
  72 + cpt++;
  73 + }
  74 +
  75 + if(now > valeurDate+3600000*2) {
  76 + if(p.getEffectuee().equals("false")){
  77 + supElementList(p,listPrises);
  78 + Intent i = new Intent(this,ServiceInitAlarme.class);
  79 + i.putExtra("heure",p.getHeure());
  80 + startService(i);
  81 + }
  82 + else{
  83 + p.setEffectuee("true");
  84 + eventBDD.updatePrise(p.getId(),p);
  85 + }
  86 + }
  87 + }
  88 + }
  89 + if(cpt == 0){
  90 + TextView textView = (TextView) findViewById(R.id.présence);
  91 + textView.setText(R.string.menu2);
  92 + }
  93 + else{
  94 + TextView textView = (TextView) findViewById(R.id.présence);
  95 + textView.setText("");
  96 + }
  97 + }
  98 +
  99 + public void onClickVomi(View view){
  100 + AlertDialog.Builder builder = new AlertDialog.Builder(this);
  101 + builder.setTitle(R.string.menu3);
  102 +
  103 + DialogInterface.OnClickListener onClickYes = new DialogInterface.OnClickListener() {
  104 + @Override
  105 + public void onClick(DialogInterface dialog, int which) {
  106 +
  107 + Date date = new Date();
  108 + SimpleDateFormat f1 = new SimpleDateFormat("dd/MM/yyyy");
  109 + SimpleDateFormat f2 = new SimpleDateFormat("HH:mm");
  110 +
  111 + String sEv = getString(R.string.menu9) + " " + f2.format(date);
  112 + Event ev = new Event(eventBDD.getIndiceMaxEvent()+1,f1.format(date),f2.format(date),sEv);
  113 + eventBDD.insertEvent(ev);
  114 +
  115 + long now = System.currentTimeMillis();
  116 +
  117 + for(int i=0; i<eventBDD.getIndiceMaxPrise(); i++){
  118 + Prise2 p = eventBDD.getPriseWithId(i+1);
  119 +
  120 + String[] decoupeDate = p.getHeure().split("h");
  121 + Calendar calendar = Calendar.getInstance();
  122 + calendar.set(Calendar.HOUR_OF_DAY,Integer.parseInt(decoupeDate[0]));
  123 + calendar.set(Calendar.MINUTE,Integer.parseInt(decoupeDate[1]));
  124 + long valeurDate = calendar.getTimeInMillis();
  125 +
  126 + if(now <= valeurDate+3600000*2){
  127 + p.setEffectuee("false");
  128 + eventBDD.updatePrise(p.getId(),p);
  129 + }
  130 + }
  131 + onResume();
  132 + }
  133 + };
  134 +
  135 + builder.setMessage(getString(R.string.menu8));
  136 + builder.setPositiveButton(R.string.oui,onClickYes);
  137 + builder.setNegativeButton(R.string.non,null);
  138 + builder.show();
  139 + }
  140 +
  141 + public void onClickButton(final Prise2 item, int position){
  142 + AlertDialog.Builder builder = new AlertDialog.Builder(this);
  143 + builder.setTitle(R.string.menu3);
  144 +
  145 + final Medicament medocAssocie = eventBDD.getMedocWithId(item.getIdMedoc());
  146 +
  147 + DialogInterface.OnClickListener onClickYes = new DialogInterface.OnClickListener() {
  148 + @Override
  149 + public void onClick(DialogInterface dialog, int which) {
  150 + supElementList(item, listPrises);
  151 + displayConfirmation(list);
  152 +
  153 + Prise2 p = eventBDD.getPriseWithId(item.getId());
  154 + p.setEffectuee("true");
  155 + eventBDD.updatePrise(p.getId(),p);
  156 +
  157 + Intent i = new Intent(MainActivity.this,ServiceInitAlarme.class);
  158 + i.putExtra("heure",p.getHeure());
  159 + startService(i);
  160 +
  161 + Date date = new Date();
  162 + SimpleDateFormat f1 = new SimpleDateFormat("dd/MM/yyyy");
  163 + SimpleDateFormat f2 = new SimpleDateFormat("HH:mm");
  164 +
  165 + String sEv = medocAssocie.getNom1() + " " + getString(R.string.menu7) + " " + f2.format(date);
  166 + Event ev = new Event(eventBDD.getIndiceMaxEvent()+1,f1.format(date),f2.format(date),sEv);
  167 + eventBDD.insertEvent(ev);
  168 + }
  169 + };
  170 +
  171 + builder.setMessage(getString(R.string.menu4) + medocAssocie.getNom1() + " ?");
  172 + builder.setPositiveButton(R.string.oui,onClickYes);
  173 + builder.setNegativeButton(R.string.non,null);
  174 + builder.show();
  175 + }
  176 +
  177 + void supElementList(Prise2 p, ArrayList<Prise2> listP){
  178 + listP.remove(p);
  179 + adapter.notifyDataSetChanged();
  180 + }
  181 +
  182 + void supList(ArrayList<Prise2> listP){
  183 + listP.clear();
  184 + adapter.notifyDataSetChanged();
  185 + }
  186 +
  187 + void addElementList(Prise2 p, ArrayList<Prise2> listP){
  188 + listP.add(p);
  189 + adapter.notifyDataSetChanged();
  190 + }
  191 +
  192 + public void displayConfirmation(View view) {
  193 + Context context = getApplicationContext();
  194 + int duration = Toast.LENGTH_LONG;
  195 + Toast toast = Toast.makeText(context, R.string.menu6, duration);
  196 + toast.setGravity(Gravity.CENTER ,0,0);
  197 + toast.show();
  198 + }
  199 +
  200 + public void onClickHistorique(View view){
  201 + Intent i = new Intent(this, HistoriqueActivity.class);
  202 + startActivity(i);
  203 + }
  204 +
  205 + public void onClickGestionMedoc(View view){
  206 + Intent i = new Intent(this, GestionActivity.class);
  207 + startActivity(i);
  208 + }
  209 +
  210 + public String chargementMedoc(String codeSource){
  211 + String nomMedoc = null, nomMolecule = null;
  212 + String posologie = null, indications = null;
  213 + String nomImage = null;
  214 + int i2 = codeSource.indexOf("</h2>");
  215 + codeSource = codeSource.substring(i2+4);
  216 + int i1 = codeSource.indexOf("<h2>")+4;
  217 + i2 = codeSource.indexOf("(");
  218 + if(i1 != -1 && i2 != -1){
  219 + nomMedoc = codeSource.substring(i1, i2);
  220 + i1 = codeSource.indexOf("(")+1;
  221 + i2 = codeSource.indexOf(")");
  222 + nomMolecule = codeSource.substring(i1, i2);
  223 + }
  224 +
  225 + i1 = codeSource.indexOf("<p><img");
  226 + i2 = codeSource.indexOf("</p>");
  227 + String image = codeSource.substring(i1,i2);
  228 + i1 = image.indexOf("src=./")+6;
  229 + i2 = image.indexOf("alt=")-1;
  230 + if(i1 != -1 && i2 != -1) nomImage = image.substring(i1,i2);
  231 +
  232 + i1 = codeSource.indexOf("<h2>Posologie</h2>") + 18;
  233 + i2 = codeSource.indexOf("<a name=content></a><h2>Indications</h2>");
  234 + if(i1 != -1 && i2 != -1) posologie = codeSource.substring(i1, i2);
  235 + i1 = codeSource.indexOf("<h2>Indications</h2>") + 20;
  236 + i2 = codeSource.indexOf("</form>");
  237 + if(i1 != -1 && i2 != -1) indications = codeSource.substring(i1, i2);
  238 + String s = nomMedoc + "XoXo" + nomMolecule + "XoXo" + nomImage + "XoXo" + posologie + "XoXo" + indications;
  239 + return s;
  240 + }
  241 +
  242 + public void onClickDownload(View view){
  243 + final ImageButton imageButton = (ImageButton) findViewById(R.id.download);
  244 + imageButton.setColorFilter(R.color.colorPrimaryDark);
  245 +
  246 + fini = false;
  247 +
  248 + new AsyncTask<String, Void, String>(){
  249 + @Override
  250 + protected String doInBackground(String... urlStr){
  251 + String htmlCode = "";
  252 + try{
  253 + URL url = new URL(urlStr[0]);
  254 + BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
  255 +
  256 + String inputLine;
  257 + while ((inputLine = in.readLine()) != null) {
  258 + htmlCode += inputLine;
  259 + }
  260 + in.close();
  261 +
  262 + } catch (Exception e) {e.printStackTrace(); fini = true;}
  263 + return htmlCode.toString();
  264 + }
  265 +
  266 + @Override
  267 + protected void onPostExecute(String codeSource){
  268 +
  269 + ArrayList<String> noms = new ArrayList<String>();
  270 + int i1 = codeSource.indexOf("<ul><li><a")+19;
  271 + int i2 = codeSource.indexOf(".html")+5;
  272 + while(i1 != -1 && i2 != -1 && i1<i2){
  273 + String nom = codeSource.substring(i1, i2);
  274 + noms.add(nom);
  275 + codeSource = codeSource.substring(i2+2+(i2-i1));
  276 + i1 = codeSource.indexOf("./");
  277 + i2 = codeSource.indexOf(".html")+5;
  278 + }
  279 +
  280 + for(String s : noms){
  281 + new AsyncTask<String, Void, String>(){
  282 + @Override
  283 + protected String doInBackground(String... urlStr){
  284 + String htmlCode = "";
  285 + try{
  286 + URL url = new URL(urlStr[0]);
  287 + BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
  288 +
  289 + String inputLine;
  290 + while ((inputLine = in.readLine()) != null) {
  291 + htmlCode += inputLine;
  292 + }
  293 + in.close();
  294 + } catch (MalformedURLException e) {
  295 + e.printStackTrace();
  296 + fini = true;
  297 + } catch (IOException e) {
  298 + filepath=null;
  299 + e.printStackTrace();
  300 + fini = true;
  301 + }
  302 + return htmlCode.toString();
  303 + }
  304 +
  305 + @Override
  306 + protected void onPostExecute(String codeSourcePage){
  307 + res += chargementMedoc(codeSourcePage);
  308 +
  309 + String[] medocdoc = res.split("XoXo");
  310 + String nom = medocdoc[0];
  311 + String nomImage = medocdoc[2];
  312 +
  313 + new AsyncTask<String, Void, String>(){
  314 + @Override
  315 + protected String doInBackground(String... urlStr){
  316 + String htmlCode = "";
  317 + try{
  318 + File SDCardRoot = Environment.getExternalStorageDirectory();
  319 + String dossier = "medicaments";
  320 + File file2 = new File(SDCardRoot,dossier);
  321 + file2.mkdir();
  322 + if(file2.createNewFile())
  323 + {
  324 + file2.createNewFile();
  325 + }
  326 +
  327 + URL url = new URL(urlStr[0]);
  328 + HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
  329 + urlConnection.setRequestMethod("GET");
  330 + urlConnection.setDoOutput(true);
  331 + urlConnection.connect();
  332 +
  333 + String filename = urlStr[0].substring(25);
  334 + int i = filename.indexOf(".");
  335 + filename = filename.substring(0,i)+".png";
  336 +
  337 + File file = new File(SDCardRoot+"/"+dossier,filename);
  338 + file.isFile();
  339 + if(file.createNewFile())
  340 + {
  341 + file.createNewFile();
  342 + }
  343 + FileOutputStream fileOutput = new FileOutputStream(file);
  344 + InputStream inputStream = urlConnection.getInputStream();
  345 + int totalSize = urlConnection.getContentLength();
  346 + int downloadedSize = 0;
  347 + byte[] buffer = new byte[1024];
  348 + int bufferLength;
  349 + while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
  350 + fileOutput.write(buffer, 0, bufferLength);
  351 + downloadedSize += bufferLength;
  352 + }
  353 + fileOutput.close();
  354 + if(downloadedSize==totalSize) filepath=file.getPath();
  355 +
  356 + } catch (MalformedURLException e) {
  357 + e.printStackTrace();
  358 + fini = true;
  359 + } catch (IOException e) {
  360 + filepath=null;
  361 + e.printStackTrace();
  362 + fini = true;
  363 + }
  364 + return htmlCode.toString();
  365 + }
  366 +
  367 + @Override
  368 + protected void onPostExecute(String codeSourcePage){
  369 + }
  370 +
  371 + @Override
  372 + protected void onCancelled(){
  373 + super.onCancelled();
  374 + Toast.makeText(MainActivity.this,R.string.menu5,Toast.LENGTH_SHORT).show();
  375 + fini = true;
  376 + }
  377 + }.execute("http://pharmacie.plil.fr/"+nomImage);
  378 +
  379 + boolean existe = false;
  380 + int indice = 0;
  381 + int w=1;
  382 + while(w <= eventBDD.getIndiceMaxMedoc() && !existe) {
  383 + Medicament m = eventBDD.getMedocWithId(w);
  384 + if (m.getNom1().equals(nom)){
  385 + existe = true;
  386 + indice = m.getIdM();
  387 + }
  388 + w++;
  389 + }
  390 + if(!existe) {
  391 + int i = medocdoc[2].indexOf(".");
  392 + medocdoc[2] = medocdoc[2].substring(0,i)+".png";
  393 + medocdoc[2] = Environment.getExternalStorageDirectory().toString()+"/medicaments/"+medocdoc[2];
  394 + Medicament m = new Medicament(eventBDD.getIndiceMaxMedoc()+1,medocdoc[0],medocdoc[1],medocdoc[3],medocdoc[4],medocdoc[2]);
  395 + eventBDD.insertMedoc(m);
  396 + }
  397 + else{
  398 + int i = medocdoc[2].indexOf(".");
  399 + medocdoc[2] = medocdoc[2].substring(0,i)+".png";
  400 + medocdoc[2] = Environment.getExternalStorageDirectory().toString()+"/medicaments/"+medocdoc[2];
  401 + Medicament m = new Medicament(indice,medocdoc[0],medocdoc[1],medocdoc[3],medocdoc[4],medocdoc[2]);
  402 + eventBDD.updateMedoc(indice,m);
  403 + }
  404 + res = "";
  405 + }
  406 + }.execute("http://pharmacie.plil.fr/"+s);
  407 + }
  408 + imageButton.clearColorFilter();
  409 + if(fini) Toast.makeText(MainActivity.this,R.string.menu5,Toast.LENGTH_SHORT).show();
  410 + else Toast.makeText(MainActivity.this,R.string.menu10,Toast.LENGTH_SHORT).show();
  411 + }
  412 +
  413 + @Override
  414 + protected void onCancelled(){
  415 + super.onCancelled();
  416 + imageButton.clearColorFilter();
  417 + Toast.makeText(MainActivity.this,R.string.menu5,Toast.LENGTH_SHORT).show();
  418 + }
  419 +
  420 + }.execute("http://pharmacie.plil.fr/liste_fiche.php");
  421 + }
  422 +
  423 + @Override
  424 + protected void onCreate(Bundle savedInstanceState) {
  425 + super.onCreate(savedInstanceState);
  426 +
  427 + requestWindowFeature(Window.FEATURE_NO_TITLE);
  428 +
  429 + setContentView(R.layout.activity_main);
  430 +
  431 + eventBDD = new StringBDD(this);
  432 + eventBDD.open();
  433 + }
  434 +
  435 + @Override
  436 + protected void onResume() {
  437 + eventBDD.open();
  438 + super.onResume();
  439 +
  440 + adapter = new PriseAdapterMenu(this,listPrises);
  441 + adapter.addListener(this);
  442 + list = (ListView)findViewById(R.id.list1);
  443 + list.setAdapter(adapter);
  444 +
  445 + gestionHeure();
  446 + }
  447 +
  448 + @Override
  449 + protected void onPause() {
  450 + eventBDD.close();
  451 + super.onPause();
  452 +
  453 + adapter = new PriseAdapterMenu(this,listPrises);
  454 + adapter.addListener(this);
  455 + list = (ListView)findViewById(R.id.list1);
  456 + list.setAdapter(adapter);
  457 +
  458 + supList(listPrises);
  459 + }
  460 +}
0 461 \ No newline at end of file
... ...
partieAndroid/codesJava/Medicament.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/Medicament.java
... ... @@ -0,0 +1,57 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +/**
  4 + * Created by martin on 20/02/2017.
  5 + */
  6 +
  7 +public class Medicament {
  8 + Integer idM;
  9 + String nom1;
  10 + String nom2;
  11 + String posologies;
  12 + String indications;
  13 + String logo;
  14 +
  15 + public Medicament(Integer mId, String mNom1, String mNom2, String poso, String indic, String mLogo){
  16 + idM = mId;
  17 + nom1 = mNom1;
  18 + nom2 = mNom2;
  19 + posologies = poso;
  20 + indications = indic;
  21 + logo = mLogo;
  22 + }
  23 +
  24 + public void setIdM(Integer idM){
  25 + this.idM = idM;
  26 + }
  27 + public void setNom1(String mNom1){
  28 + nom1 = mNom1;
  29 + }
  30 + public void setNom2(String mNom2){
  31 + nom2 = mNom2;
  32 + }
  33 + public void setPosologies(String poso) {
  34 + posologies = poso;
  35 + }
  36 + public void setIndications(String indic) {
  37 + indications = indic;
  38 + }
  39 + public void setLogo(String mLogo){
  40 + logo = mLogo;
  41 + }
  42 +
  43 + public Integer getIdM(){
  44 + return idM;
  45 + }
  46 + public String getNom1(){
  47 + return nom1;
  48 + }
  49 + public String getNom2(){
  50 + return nom2;
  51 + }
  52 + public String getPosologies(){ return posologies; }
  53 + public String getIndications(){ return indications; }
  54 + public String getLogo(){
  55 + return logo;
  56 + }
  57 +}
... ...
partieAndroid/codesJava/MedocAdapterMenu.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/MedocAdapterMenu.java
... ... @@ -0,0 +1,96 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.Bitmap;
  5 +import android.graphics.BitmapFactory;
  6 +import android.view.LayoutInflater;
  7 +import android.view.View;
  8 +import android.view.ViewGroup;
  9 +import android.widget.BaseAdapter;
  10 +import android.widget.ImageButton;
  11 +import android.widget.ImageView;
  12 +import android.widget.RelativeLayout;
  13 +import android.widget.TextView;
  14 +
  15 +import java.io.File;
  16 +import java.util.ArrayList;
  17 +import java.util.List;
  18 +
  19 +/**
  20 + * Created by martin on 12/04/2017.
  21 + */
  22 +
  23 +public class MedocAdapterMenu extends BaseAdapter {
  24 + public List<Medicament> mListM;
  25 + public Context mContext;
  26 + public LayoutInflater mInflater;
  27 +
  28 + public MedocAdapterMenu(Context context, List<Medicament> aListM){
  29 + mContext = context;
  30 + mListM = aListM;
  31 + mInflater = LayoutInflater.from(mContext);
  32 + }
  33 +
  34 + public int getCount(){
  35 + return mListM.size();
  36 + }
  37 +
  38 + public Object getItem(int position){
  39 + return mListM.get(position);
  40 + }
  41 +
  42 + public long getItemId(int position){
  43 + return position;
  44 + }
  45 +
  46 + public View getView(int position, View convertView, ViewGroup parent) {
  47 + RelativeLayout layoutItem;
  48 +
  49 + if (convertView == null) {
  50 + layoutItem = (RelativeLayout) mInflater.inflate(R.layout.medoc, parent, false);
  51 + } else {
  52 + layoutItem = (RelativeLayout) convertView;
  53 + }
  54 +
  55 + TextView nom1 = (TextView)layoutItem.findViewById(R.id.nom1);
  56 + TextView nom2 = (TextView)layoutItem.findViewById(R.id.nom2);
  57 + ImageView logo = (ImageView)layoutItem.findViewById(R.id.logo);
  58 + ImageButton modif = (ImageButton) layoutItem.findViewById(R.id.boutonModif);
  59 +
  60 + nom1.setText(mListM.get(position).getNom1());
  61 + nom2.setText(mListM.get(position).getNom2());
  62 +
  63 + File imgFile = new File(mListM.get(position).getLogo());
  64 + if(imgFile.exists()){
  65 + Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
  66 + logo.setImageBitmap(myBitmap);
  67 + }
  68 +
  69 + modif.setTag(position);
  70 + modif.setOnClickListener(new View.OnClickListener(){
  71 + @Override
  72 + public void onClick(View v){
  73 + Integer position = (Integer)v.getTag();
  74 + sendListener(mListM.get(position),position);
  75 + }
  76 + });
  77 +
  78 + return layoutItem;
  79 + }
  80 +
  81 + public interface MedocAdapterListener{
  82 + void onClickButton(Medicament item, int position);
  83 + }
  84 +
  85 + private ArrayList<MedocAdapterMenu.MedocAdapterListener> mListListener = new ArrayList<MedocAdapterListener>();
  86 +
  87 + public void addListener(MedocAdapterMenu.MedocAdapterListener aListener){
  88 + mListListener.add(aListener);
  89 + }
  90 +
  91 + private void sendListener(Medicament item, int position){
  92 + for(int i = mListListener.size()-1; i>=0; i--){
  93 + mListListener.get(i).onClickButton(item, position);
  94 + }
  95 + }
  96 +}
... ...
partieAndroid/codesJava/ModifMedocActivity.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/ModifMedocActivity.java
... ... @@ -0,0 +1,208 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.DialogInterface;
  4 +import android.content.Intent;
  5 +import android.graphics.Bitmap;
  6 +import android.graphics.BitmapFactory;
  7 +import android.os.Bundle;
  8 +import android.support.v7.app.AlertDialog;
  9 +import android.support.v7.app.AppCompatActivity;
  10 +import android.view.View;
  11 +import android.widget.EditText;
  12 +import android.widget.ImageView;
  13 +import android.widget.ListView;
  14 +import android.widget.TextView;
  15 +import android.widget.Toast;
  16 +
  17 +import java.util.ArrayList;
  18 +import java.util.Collections;
  19 +
  20 +/**
  21 + * Created by martin on 12/04/2017.
  22 + */
  23 +
  24 +public class ModifMedocActivity extends AppCompatActivity implements PriseAdapterMedoc.PriseAdapterListener {
  25 +
  26 + ArrayList<Prise2> listPrises = new ArrayList<>();
  27 + PriseAdapterMedoc adapter = null;
  28 + ListView list = null;
  29 + StringBDD eventBDD = null;
  30 + Medicament medicament = null;
  31 +
  32 + void supElementList(Prise2 p, ArrayList<Prise2> listP){
  33 + listP.remove(p);
  34 + adapter.notifyDataSetChanged();
  35 + }
  36 +
  37 + void supList(ArrayList<Prise2> listP){
  38 + listP.clear();
  39 + adapter.notifyDataSetChanged();
  40 + }
  41 +
  42 + void addElementList(Prise2 p, ArrayList<Prise2> listP){
  43 + listP.add(p);
  44 + }
  45 +
  46 + public void onClickDelete(final Prise2 item, int position){
  47 + AlertDialog.Builder builder = new AlertDialog.Builder(this);
  48 +
  49 + DialogInterface.OnClickListener onClickYes = new DialogInterface.OnClickListener() {
  50 + @Override
  51 + public void onClick(DialogInterface dialog, int which) {
  52 + supElementList(item, listPrises);
  53 + eventBDD.removePriseWithID(item.getId());
  54 +
  55 + }
  56 + };
  57 +
  58 + builder.setMessage(R.string.modif8);
  59 + builder.setPositiveButton(R.string.oui,onClickYes);
  60 + builder.setNegativeButton(R.string.non,null);
  61 + builder.show();
  62 + }
  63 +
  64 + void gestionPrises(){
  65 + for(int w=0; w<eventBDD.getIndiceMaxPrise(); w++) {
  66 + Prise2 p = eventBDD.getPriseWithId(w + 1);
  67 + if (p != null) {
  68 + if (p.getIdMedoc() == medicament.getIdM()) addElementList(p, listPrises);
  69 + }
  70 + }
  71 + Collections.sort(listPrises);
  72 + adapter.notifyDataSetChanged();
  73 + }
  74 +
  75 + public void onClickInfos(View view){
  76 + AlertDialog.Builder builder = new AlertDialog.Builder(this);
  77 +
  78 + String mes =
  79 + getString(R.string.modif2) + "\n" + medicament.getNom1() +
  80 + "\n\n" + getString(R.string.modif3) + "\n" + medicament.getNom2() +
  81 + "\n\n" + getString(R.string.modif4) + "\n" + medicament.getPosologies() +
  82 + "\n\n" + getString(R.string.modif5) + "\n" + medicament.getIndications()
  83 + ;
  84 +
  85 + builder.setMessage(mes);
  86 + builder.setNeutralButton(R.string.ok,null);
  87 + builder.show();
  88 + }
  89 +
  90 + public void onClickRetour(View view){
  91 + Intent i = new Intent(this, MainActivity.class);
  92 + startActivity(i);
  93 + }
  94 +
  95 + public void onClickAjoutPrise(final View view){
  96 + AlertDialog.Builder builder = new AlertDialog.Builder(this);
  97 + builder.setTitle(R.string.modif6);
  98 + builder.setMessage(R.string.modif7);
  99 +
  100 + final EditText editText = new EditText(this);
  101 + editText.setHint("ex : 12h30");
  102 + editText.setTextSize(20);
  103 + builder.setView(editText);
  104 +
  105 + DialogInterface.OnClickListener onClickYes = new DialogInterface.OnClickListener() {
  106 +
  107 + @Override
  108 + public void onClick(DialogInterface dialog, int which) {
  109 + try {
  110 + String[] decoupe = editText.getText().toString().split("h");
  111 + int size = decoupe.length;
  112 + Integer h, m;
  113 +
  114 + if (size > 2 || decoupe[0].equals(""))
  115 + Toast.makeText(view.getContext(), R.string.modif9, Toast.LENGTH_SHORT).show();
  116 + else {
  117 + h = Integer.parseInt(decoupe[0]);
  118 + if (size == 1) m = 0;
  119 + else m = Integer.parseInt(decoupe[1]);
  120 +
  121 + String s;
  122 + if (h >= 24 || h < 0)
  123 + Toast.makeText(view.getContext(), R.string.modif9, Toast.LENGTH_SHORT).show();
  124 + else {
  125 + if (m >= 60 || m < 0)
  126 + Toast.makeText(view.getContext(), R.string.modif9, Toast.LENGTH_SHORT).show();
  127 + else {
  128 + if (m == 0) s = h.toString() + "h" + "0" + m.toString();
  129 + else s = h.toString() + "h" + m.toString();
  130 +
  131 + int w=1;
  132 + boolean out = false;
  133 + while(w <= eventBDD.getIndiceMaxPrise() && !out){
  134 + Prise2 p = eventBDD.getPriseWithId(w);
  135 + if(p == null) out = true;
  136 + else w++;
  137 + }
  138 +
  139 + Prise2 p = new Prise2(w, medicament.getIdM(), "false", s);
  140 + eventBDD.insertPrise(p);
  141 +
  142 + Intent i = new Intent(ModifMedocActivity.this, ServiceInitAlarme.class);
  143 + i.putExtra("heure", p.getHeure());
  144 + startService(i);
  145 +
  146 + supList(listPrises);
  147 + gestionPrises();
  148 + }
  149 + }
  150 + }
  151 + }catch (Exception e){
  152 + Toast.makeText(ModifMedocActivity.this,R.string.modif9,Toast.LENGTH_SHORT).show();
  153 + }
  154 + }
  155 + };
  156 +
  157 + builder.setPositiveButton(R.string.enregistrer,onClickYes);
  158 + builder.setNegativeButton(R.string.annuler,null);
  159 + builder.show();
  160 + }
  161 +
  162 + @Override
  163 + protected void onCreate(Bundle savedInstanceState) {
  164 + super.onCreate(savedInstanceState);
  165 + setContentView(R.layout.modif_layout);
  166 +
  167 + eventBDD = new StringBDD(this);
  168 + eventBDD.open();
  169 +
  170 + Intent intent = getIntent();
  171 + Integer idMedoc = intent.getIntExtra("id",0);
  172 + medicament = eventBDD.getMedocWithId(idMedoc);
  173 +
  174 + ImageView logo = (ImageView) findViewById(R.id.logo);
  175 + Bitmap bitmap = BitmapFactory.decodeFile(medicament.getLogo());
  176 + logo.setImageBitmap(bitmap);
  177 + TextView nom1 = (TextView) findViewById(R.id.nom1);
  178 + nom1.setText(medicament.getNom1());
  179 + TextView nom2 = (TextView) findViewById(R.id.nom2);
  180 + nom2.setText(medicament.getNom2());
  181 + }
  182 +
  183 + @Override
  184 + protected void onResume() {
  185 + eventBDD.open();
  186 + super.onResume();
  187 +
  188 + adapter = new PriseAdapterMedoc(this,listPrises);
  189 + adapter.addListener(this);
  190 + list = (ListView)findViewById(R.id.listePrises);
  191 + list.setAdapter(adapter);
  192 +
  193 + gestionPrises();
  194 + }
  195 +
  196 + @Override
  197 + protected void onPause() {
  198 + super.onPause();
  199 +
  200 + adapter = new PriseAdapterMedoc(this,listPrises);
  201 + adapter.addListener(this);
  202 + list = (ListView)findViewById(R.id.listePrises);
  203 + list.setAdapter(adapter);
  204 +
  205 + eventBDD.close();
  206 + supList(listPrises);
  207 + }
  208 +}
0 209 \ No newline at end of file
... ...
partieAndroid/codesJava/Prise2.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/Prise2.java
... ... @@ -0,0 +1,74 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +/**
  4 + * Created by martin on 20/02/2017.
  5 + */
  6 +
  7 +public class Prise2 implements Comparable<Prise2>{
  8 + Integer idP;
  9 + Integer idMedoc;
  10 + String effectuee;
  11 + String heurePrescrite;
  12 +
  13 + public Prise2(Integer pId, Integer pIdMedoc, String pEffectuee, String pHeure) {
  14 + idP = pId;
  15 + idMedoc = pIdMedoc;
  16 + effectuee = pEffectuee;
  17 + heurePrescrite = pHeure;
  18 + }
  19 +
  20 + @Override
  21 + public int compareTo(Prise2 p) {
  22 + String[] s1 = this.getHeure().split("h");
  23 + String[] s2 = p.getHeure().split("h");
  24 +
  25 + int cmp;
  26 + if (Integer.parseInt(s1[0]) > Integer.parseInt(s2[0]))
  27 + cmp = +1;
  28 + else if (Integer.parseInt(s1[0]) < Integer.parseInt(s2[0]))
  29 + cmp = -1;
  30 + else{
  31 + if (Integer.parseInt(s1[1]) > Integer.parseInt(s2[1]))
  32 + cmp = +1;
  33 + else if (Integer.parseInt(s1[1]) < Integer.parseInt(s2[1]))
  34 + cmp = -1;
  35 + else
  36 + cmp = 0;
  37 + }
  38 +
  39 + return cmp;
  40 +
  41 + /*
  42 + if(s1[0].compareTo(s2[0]) == 0){;
  43 + return s1[1].compareTo(s2[1]);
  44 + }
  45 + else return s1[0].compareTo(s2[0]);
  46 + */
  47 + }
  48 +
  49 + public void setId(Integer pId){
  50 + idP = pId;
  51 + }
  52 + public void setIdMedoc(Integer pIdM){
  53 + idMedoc = pIdM;
  54 + }
  55 + public void setEffectuee(String pEffectuee){
  56 + effectuee = pEffectuee;
  57 + }
  58 + public void setHeure(String pHeure){
  59 + heurePrescrite = pHeure;
  60 + }
  61 +
  62 + public Integer getId(){
  63 + return idP;
  64 + }
  65 + public Integer getIdMedoc(){
  66 + return idMedoc;
  67 + }
  68 + public String getEffectuee(){
  69 + return effectuee;
  70 + }
  71 + public String getHeure(){
  72 + return heurePrescrite;
  73 + }
  74 +}
... ...
partieAndroid/codesJava/PriseAdapterMedoc.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/PriseAdapterMedoc.java
... ... @@ -0,0 +1,84 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.Context;
  4 +import android.view.LayoutInflater;
  5 +import android.view.View;
  6 +import android.view.ViewGroup;
  7 +import android.widget.BaseAdapter;
  8 +import android.widget.ImageButton;
  9 +import android.widget.RelativeLayout;
  10 +import android.widget.TextView;
  11 +
  12 +import java.util.ArrayList;
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * Created by martin on 20/02/2017.
  17 + */
  18 +
  19 +public class PriseAdapterMedoc extends BaseAdapter {
  20 + public List<Prise2> mListP;
  21 + public Context mContext;
  22 + public LayoutInflater mInflater;
  23 +
  24 + public PriseAdapterMedoc(Context context, List<Prise2> aListP){
  25 + mContext = context;
  26 + mListP = aListP;
  27 + mInflater = LayoutInflater.from(mContext);
  28 + }
  29 +
  30 + public int getCount(){
  31 + return mListP.size();
  32 + }
  33 +
  34 + public Object getItem(int position){
  35 + return mListP.get(position);
  36 + }
  37 +
  38 + public long getItemId(int position){
  39 + return position;
  40 + }
  41 +
  42 + public View getView(int position, View convertView, ViewGroup parent) {
  43 + RelativeLayout layoutItem;
  44 +
  45 + if (convertView == null) {
  46 + layoutItem = (RelativeLayout) mInflater.inflate(R.layout.prise_medoc, parent, false);
  47 + } else {
  48 + layoutItem = (RelativeLayout) convertView;
  49 + }
  50 +
  51 + TextView horloge = (TextView) layoutItem.findViewById(R.id.horloge);
  52 + ImageButton change = (ImageButton) layoutItem.findViewById(R.id.boutonConfirm);
  53 +
  54 + horloge.setText(mListP.get(position).getHeure());
  55 + change.setImageResource(R.drawable.delete);
  56 +
  57 + change.setTag(position);
  58 + change.setOnClickListener(new View.OnClickListener(){
  59 + @Override
  60 + public void onClick(View v){
  61 + Integer position = (Integer)v.getTag();
  62 + sendListener(mListP.get(position),position);
  63 + }
  64 + });
  65 +
  66 + return layoutItem;
  67 + }
  68 +
  69 + public interface PriseAdapterListener{
  70 + void onClickDelete(Prise2 item, int position);
  71 + }
  72 +
  73 + private ArrayList<PriseAdapterListener> mListListener = new ArrayList<PriseAdapterListener>();
  74 +
  75 + public void addListener(PriseAdapterListener aListener){
  76 + mListListener.add(aListener);
  77 + }
  78 +
  79 + private void sendListener(Prise2 item, int position){
  80 + for(int i = mListListener.size()-1; i>=0; i--){
  81 + mListListener.get(i).onClickDelete(item, position);
  82 + }
  83 + }
  84 +}
... ...
partieAndroid/codesJava/PriseAdapterMenu.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/PriseAdapterMenu.java
... ... @@ -0,0 +1,102 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.Bitmap;
  5 +import android.graphics.BitmapFactory;
  6 +import android.view.LayoutInflater;
  7 +import android.view.View;
  8 +import android.view.ViewGroup;
  9 +import android.widget.BaseAdapter;
  10 +import android.widget.ImageButton;
  11 +import android.widget.ImageView;
  12 +import android.widget.RelativeLayout;
  13 +import android.widget.TextView;
  14 +
  15 +import java.io.File;
  16 +import java.util.ArrayList;
  17 +import java.util.List;
  18 +
  19 +/**
  20 + * Created by martin on 27/04/2017.
  21 + */
  22 +
  23 +public class PriseAdapterMenu extends BaseAdapter {
  24 + public List<Prise2> mListP;
  25 + public Context mContext;
  26 + public LayoutInflater mInflater;
  27 + public StringBDD eventBDD;
  28 +
  29 + public PriseAdapterMenu(Context context, List<Prise2> aListP){
  30 + mContext = context;
  31 + mListP = aListP;
  32 + mInflater = LayoutInflater.from(mContext);
  33 + }
  34 +
  35 + public int getCount(){
  36 + return mListP.size();
  37 + }
  38 +
  39 + public Object getItem(int position){
  40 + return mListP.get(position);
  41 + }
  42 +
  43 + public long getItemId(int position){
  44 + return position;
  45 + }
  46 +
  47 + public View getView(int position, View convertView, ViewGroup parent) {
  48 + RelativeLayout layoutItem;
  49 +
  50 + if (convertView == null) {
  51 + layoutItem = (RelativeLayout) mInflater.inflate(R.layout.prise_menu, parent, false);
  52 + } else {
  53 + layoutItem = (RelativeLayout) convertView;
  54 + }
  55 +
  56 + ImageView logoMedoc = (ImageView) layoutItem.findViewById(R.id.logoMenu);
  57 + TextView horloge = (TextView) layoutItem.findViewById(R.id.horlogeMenu);
  58 + TextView nom = (TextView) layoutItem.findViewById(R.id.nomMenu);
  59 + ImageButton change = (ImageButton) layoutItem.findViewById(R.id.boutonConfirmMenu);
  60 +
  61 + eventBDD = new StringBDD(null);
  62 + eventBDD.open();
  63 + Medicament m = eventBDD.getMedocWithId(mListP.get(position).getIdMedoc());
  64 + nom.setText(m.getNom1());
  65 + File imgFile = new File(m.getLogo());
  66 + if(imgFile.exists()){
  67 + Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
  68 + logoMedoc.setImageBitmap(myBitmap);
  69 + }
  70 +
  71 +
  72 + horloge.setText(mListP.get(position).getHeure());
  73 + change.setImageResource(R.drawable.edit);
  74 +
  75 + change.setTag(position);
  76 + change.setOnClickListener(new View.OnClickListener(){
  77 + @Override
  78 + public void onClick(View v){
  79 + Integer position = (Integer)v.getTag();
  80 + sendListener(mListP.get(position),position);
  81 + }
  82 + });
  83 +
  84 + return layoutItem;
  85 + }
  86 +
  87 + public interface PriseAdapterListener{
  88 + void onClickButton(Prise2 item, int position);
  89 + }
  90 +
  91 + private ArrayList<PriseAdapterListener> mListListener = new ArrayList<PriseAdapterListener>();
  92 +
  93 + public void addListener(PriseAdapterListener aListener){
  94 + mListListener.add(aListener);
  95 + }
  96 +
  97 + private void sendListener(Prise2 item, int position){
  98 + for(int i = mListListener.size()-1; i>=0; i--){
  99 + mListListener.get(i).onClickButton(item, position);
  100 + }
  101 + }
  102 +}
... ...
partieAndroid/codesJava/ServiceInitAlarme.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/ServiceInitAlarme.java
... ... @@ -0,0 +1,36 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.app.Service;
  4 +import android.content.Intent;
  5 +import android.os.IBinder;
  6 +
  7 +/**
  8 + * Created by martin on 06/05/2017.
  9 + */
  10 +
  11 +public class ServiceInitAlarme extends Service {
  12 + Alarm alarm = new Alarm();
  13 + public void onCreate()
  14 + {
  15 + super.onCreate();
  16 + }
  17 +
  18 + @Override
  19 + public int onStartCommand(Intent intent, int flags, int startId)
  20 + {
  21 + String s = intent.getStringExtra("heure");
  22 + alarm.setAlarm(this,s);
  23 + return START_STICKY;
  24 + }
  25 +
  26 + @Override
  27 + public IBinder onBind(Intent intent)
  28 + {
  29 + return null;
  30 + }
  31 +
  32 + @Override
  33 + public void onDestroy(){
  34 + super.onDestroy();
  35 + }
  36 +}
... ...
partieAndroid/codesJava/StringBDD.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/StringBDD.java
... ... @@ -0,0 +1,247 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.ContentValues;
  4 +import android.content.Context;
  5 +import android.database.Cursor;
  6 +import android.database.sqlite.SQLiteDatabase;
  7 +
  8 +/**
  9 + * Created by martin on 21/02/2017.
  10 + */
  11 +
  12 +public class StringBDD {
  13 + private static final String TABLE_EVENTS = "table_events";
  14 + private static final String COL_ID_EV = "ID_ev";
  15 + private static final int NUM_COL_ID_EV = 0;
  16 + private static final String COL_DATE = "Date";
  17 + private static final int NUM_COL_DATE = 1;
  18 + private static final String COL_HEURE_EV = "Heure_ev";
  19 + private static final int NUM_COL_HEURE_EV = 2;
  20 + private static final String COL_EVENT = "Event";
  21 + private static final int NUM_COL_EVENT = 3;
  22 +
  23 + private static final String TABLE_PRISES = "table_prises";
  24 + private static final String COL_ID_P = "ID_prise";
  25 + private static final int NUM_COL_ID_P = 0;
  26 + private static final String COL_MEDOC = "Medoc";
  27 + private static final int NUM_COL_MEDOC = 1;
  28 + private static final String COL_HEURE = "Heure";
  29 + private static final int NUM_COL_HEURE = 2;
  30 + private static final String COL_BOOL = "Bool";
  31 + private static final int NUM_COL_BOOL = 3;
  32 +
  33 + private static final String TABLE_MEDOCS = "table_medocs";
  34 + private static final String COL_ID_M = "ID_medoc";
  35 + private static final int NUM_COL_ID_M = 0;
  36 + private static final String COL_NOM1 = "Nom1";
  37 + private static final int NUM_COL_NOM1 = 1;
  38 + private static final String COL_NOM2 = "Nom2";
  39 + private static final int NUM_COL_NOM2 = 2;
  40 + private static final String COL_POSO = "Posologies";
  41 + private static final int NUM_COL_POSO = 3;
  42 + private static final String COL_INFOS = "Indications";
  43 + private static final int NUM_COL_INFOS = 4;
  44 + private static final String COL_LOGO = "Logo";
  45 + private static final int NUM_COL_LOGO = 5;
  46 +
  47 + private SQLiteDatabase bdd;
  48 +
  49 + private StringSQLite maBaseSQLite;
  50 +
  51 + private static final int VERSION_BDD = 1;
  52 +
  53 + public StringBDD(Context context) {
  54 + maBaseSQLite = StringSQLite.getInstance(context);
  55 + }
  56 +
  57 + public void open() {
  58 + bdd = maBaseSQLite.getWritableDatabase();
  59 + }
  60 +
  61 + public void close() {
  62 + bdd.close();
  63 + }
  64 +
  65 + public SQLiteDatabase getBDD() {
  66 + return bdd;
  67 + }
  68 +
  69 + //------- Gestion BDD event -----------
  70 +
  71 + public long insertEvent(Event ev) {
  72 + //Création d'un ContentValues (fonctionne comme une HashMap)
  73 + ContentValues values = new ContentValues();
  74 + //on lui ajoute une valeur associée à une clé (qui est le nom de la colonne dans laquelle on veut mettre la valeur)
  75 + values.put(COL_ID_EV, ev.getId());
  76 + values.put(COL_DATE, ev.getDate());
  77 + values.put(COL_HEURE_EV, ev.getHeure());
  78 + values.put(COL_EVENT, ev.getEvenement());
  79 + //on insère l'objet dans la BDD via le ContentValues
  80 + return bdd.insert(TABLE_EVENTS, null, values);
  81 + }
  82 +
  83 + public int getIndiceMaxEvent(){
  84 + Cursor c = bdd.rawQuery("select "+COL_ID_EV+" from "+TABLE_EVENTS,null);
  85 + return c.getCount();
  86 + }
  87 +
  88 + public Event getEventWithId(Integer id){
  89 + //Récupère dans un Cursor les valeurs correspondant à une prise contenue dans la BDD (ici on sélectionne la prise grâce à son titre)
  90 + Cursor c = bdd.query(TABLE_EVENTS, new String[] {COL_ID_EV, COL_DATE, COL_HEURE_EV, COL_EVENT}, COL_ID_EV + " LIKE \"" + id +"\"", null, null, null, null);
  91 + return cursorToEvent(c);
  92 + }
  93 +
  94 + //Cette méthode permet de convertir un cursor en une prise
  95 + private Event cursorToEvent(Cursor c){
  96 + //si aucun élément n'a été retourné dans la requête, on renvoie null
  97 + if (c.getCount() == 0)
  98 + return null;
  99 +
  100 + //Sinon on se place sur le premier élément
  101 + c.moveToFirst();
  102 + //On créé une prise
  103 + Event ev = new Event(null,null,null,null);
  104 + //on lui affecte toutes les infos grâce aux infos contenues dans le Cursor
  105 + ev.setId(c.getInt(NUM_COL_ID_EV));
  106 + ev.setDate(c.getString(NUM_COL_DATE));
  107 + ev.setHeure(c.getString(NUM_COL_HEURE_EV));
  108 + ev.setEvenement(c.getString(NUM_COL_EVENT));
  109 + //On ferme le cursor
  110 + c.close();
  111 +
  112 + //On retourne la prise
  113 + return ev;
  114 + }
  115 +
  116 + //------- Gestion BDD prises -----------
  117 +
  118 + public long insertPrise(Prise2 prise){
  119 + //Création d'un ContentValues (fonctionne comme une HashMap)
  120 + ContentValues values = new ContentValues();
  121 + //on lui ajoute une valeur associée à une clé (qui est le nom de la colonne dans laquelle on veut mettre la valeur)
  122 + values.put(COL_ID_P,prise.getId());
  123 + values.put(COL_MEDOC, prise.getIdMedoc());
  124 + values.put(COL_HEURE, prise.getHeure());
  125 + values.put(COL_BOOL, prise.getEffectuee());
  126 + //on insère l'objet dans la BDD via le ContentValues
  127 + return bdd.insert(TABLE_PRISES, null, values);
  128 + }
  129 +
  130 + public int updatePrise(int id, Prise2 prise){
  131 + //La mise à jour d'une prise dans la BDD fonctionne plus ou moins comme une insertion
  132 + //il faut simplement préciser quelle prise on doit mettre à jour grâce à l'ID
  133 + ContentValues values = new ContentValues();
  134 + values.put(COL_ID_P, prise.getId());
  135 + values.put(COL_MEDOC, prise.getIdMedoc());
  136 + values.put(COL_HEURE, prise.getHeure());
  137 + values.put(COL_BOOL, prise.getEffectuee());
  138 + return bdd.update(TABLE_PRISES, values, COL_ID_P + " = " +id, null);
  139 + }
  140 +
  141 + public int removePriseWithID(int id){
  142 + //Suppression d'une prise de la BDD grâce à l'ID
  143 + return bdd.delete(TABLE_PRISES, COL_ID_P + " = " +id, null);
  144 + }
  145 +
  146 + public Prise2 getPriseWithId(Integer id){
  147 + //Récupère dans un Cursor les valeurs correspondant à une prise contenue dans la BDD (ici on sélectionne la prise grâce à son titre)
  148 + Cursor c = bdd.query(TABLE_PRISES, new String[] {COL_ID_P, COL_MEDOC, COL_HEURE, COL_BOOL}, COL_ID_P + " LIKE \"" + id +"\"", null, null, null, null);
  149 + return cursorToPrise(c);
  150 + }
  151 +
  152 + public int getIndiceMaxPrise(){
  153 + Cursor c = bdd.rawQuery("select "+COL_ID_P+" from "+TABLE_PRISES,null);
  154 + return c.getCount();
  155 + }
  156 +
  157 + //Cette méthode permet de convertir un cursor en une prise
  158 + private Prise2 cursorToPrise(Cursor c){
  159 + //si aucun élément n'a été retourné dans la requête, on renvoie null
  160 + if (c.getCount() == 0)
  161 + return null;
  162 +
  163 + //Sinon on se place sur le premier élément
  164 + c.moveToFirst();
  165 + //On créé une prise
  166 + Prise2 prise = new Prise2(null,null,null,null);
  167 + //on lui affecte toutes les infos grâce aux infos contenues dans le Cursor
  168 + prise.setId(c.getInt(NUM_COL_ID_P));
  169 + prise.setIdMedoc(c.getInt(NUM_COL_MEDOC));
  170 + prise.setHeure(c.getString(NUM_COL_HEURE));
  171 + prise.setEffectuee(c.getString(NUM_COL_BOOL));
  172 + //On ferme le cursor
  173 + c.close();
  174 +
  175 + //On retourne la prise
  176 + return prise;
  177 + }
  178 +
  179 + //------- Gestion BDD medocs -----------
  180 +
  181 + public long insertMedoc(Medicament medicament){
  182 + //Création d'un ContentValues (fonctionne comme une HashMap)
  183 + ContentValues values = new ContentValues();
  184 + //on lui ajoute une valeur associée à une clé (qui est le nom de la colonne dans laquelle on veut mettre la valeur)
  185 + values.put(COL_ID_M, medicament.getIdM());
  186 + values.put(COL_NOM1, medicament.getNom1());
  187 + values.put(COL_NOM2, medicament.getNom2());
  188 + values.put(COL_POSO, medicament.getPosologies());
  189 + values.put(COL_INFOS, medicament.getIndications());
  190 + values.put(COL_LOGO, medicament.getLogo());
  191 + //on insère l'objet dans la BDD via le ContentValues
  192 + return bdd.insert(TABLE_MEDOCS, null, values);
  193 + }
  194 +
  195 + public int updateMedoc(int id, Medicament medicament){
  196 + //La mise à jour d'une prise dans la BDD fonctionne plus ou moins comme une insertion
  197 + //il faut simplement préciser quelle prise on doit mettre à jour grâce à l'ID
  198 + ContentValues values = new ContentValues();
  199 + values.put(COL_ID_M, medicament.getIdM());
  200 + values.put(COL_NOM1, medicament.getNom1());
  201 + values.put(COL_NOM2, medicament.getNom2());
  202 + values.put(COL_POSO, medicament.getPosologies());
  203 + values.put(COL_INFOS, medicament.getIndications());
  204 + values.put(COL_LOGO, medicament.getLogo());
  205 + return bdd.update(TABLE_MEDOCS, values, COL_ID_M + " = " +id, null);
  206 + }
  207 +
  208 + public Medicament getMedocWithId(Integer id){
  209 + //Récupère dans un Cursor les valeurs correspondant à une prise contenue dans la BDD (ici on sélectionne la prise grâce à son titre)
  210 + Cursor c = bdd.query(TABLE_MEDOCS, new String[] {COL_ID_M, COL_NOM1, COL_NOM2, COL_POSO, COL_INFOS, COL_LOGO}, COL_ID_M + " LIKE \"" + id +"\"", null, null, null, null);
  211 + return cursorToMedoc(c);
  212 + }
  213 +
  214 + public Medicament getMedocWithNom1(String nom){
  215 + //Récupère dans un Cursor les valeurs correspondant à une prise contenue dans la BDD (ici on sélectionne la prise grâce à son titre)
  216 + Cursor c = bdd.query(TABLE_MEDOCS, new String[] {COL_ID_M, COL_NOM1, COL_NOM2, COL_POSO, COL_INFOS, COL_LOGO}, COL_NOM1 + " LIKE \"" + nom +"\"", null, null, null, null);
  217 + return cursorToMedoc(c);
  218 + }
  219 +
  220 + public int getIndiceMaxMedoc(){
  221 + Cursor c = bdd.rawQuery("select "+COL_ID_M+" from "+TABLE_MEDOCS,null);
  222 + return c.getCount();
  223 + }
  224 +
  225 + private Medicament cursorToMedoc(Cursor c){
  226 + //si aucun élément n'a été retourné dans la requête, on renvoie null
  227 + if (c.getCount() == 0)
  228 + return null;
  229 +
  230 + //Sinon on se place sur le premier élément
  231 + c.moveToFirst();
  232 + //On créé une prise
  233 + Medicament medicament = new Medicament(null,null,null,null,null,null);
  234 + //on lui affecte toutes les infos grâce aux infos contenues dans le Cursor
  235 + medicament.setIdM(c.getInt(NUM_COL_ID_M));
  236 + medicament.setNom1(c.getString(NUM_COL_NOM1));
  237 + medicament.setNom2(c.getString(NUM_COL_NOM2));
  238 + medicament.setPosologies(c.getString(NUM_COL_POSO));
  239 + medicament.setIndications(c.getString(NUM_COL_INFOS));
  240 + medicament.setLogo(c.getString(NUM_COL_LOGO));
  241 + //On ferme le cursor
  242 + c.close();
  243 +
  244 + //On retourne la prise
  245 + return medicament;
  246 + }
  247 +}
... ...
partieAndroid/codesJava/StringSQLite.java 0 → 100644
  1 +++ a/partieAndroid/codesJava/StringSQLite.java
... ... @@ -0,0 +1,75 @@
  1 +package com.example.martin.projetv5;
  2 +
  3 +import android.content.Context;
  4 +import android.database.sqlite.SQLiteDatabase;
  5 +import android.database.sqlite.SQLiteOpenHelper;
  6 +
  7 +/**
  8 + * Created by martin on 21/02/2017.
  9 + */
  10 +
  11 +public class StringSQLite extends SQLiteOpenHelper {
  12 + private static final int VERSION_BDD = 1;
  13 + private static final String NOM_BDD = "evenements.db";
  14 + private static StringSQLite sInstance;
  15 +
  16 + private static final String TABLE_EVENTS = "table_events";
  17 + private static final String TABLE_PRISES = "table_prises";
  18 + private static final String TABLE_MEDOCS = "table_medocs";
  19 +
  20 + private static final String COL_ID_EV = "ID_ev";
  21 + private static final String COL_DATE = "Date";
  22 + private static final String COL_HEURE_EV = "Heure_ev";
  23 + private static final String COL_EVENT = "Event";
  24 +
  25 + private static final String COL_ID_P = "ID_prise";
  26 + private static final String COL_MEDOC = "Medoc";
  27 + private static final String COL_HEURE = "Heure";
  28 + private static final String COL_BOOL = "Bool";
  29 +
  30 + private static final String COL_ID_M = "ID_medoc";
  31 + private static final String COL_NOM1 = "Nom1";
  32 + private static final String COL_NOM2 = "Nom2";
  33 + private static final String COL_POSO = "Posologies";
  34 + private static final String COL_INFOS = "Indications";
  35 + private static final String COL_LOGO = "Logo";
  36 +
  37 + private static final String CREATE_BDD = "CREATE TABLE " + TABLE_EVENTS + " ("
  38 + + COL_ID_EV + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_DATE + " TEXT NOT NULL, "
  39 + + COL_HEURE_EV + " TEXT NOT NULL, " + COL_EVENT + " TEXT NOT NULL);";
  40 +
  41 + private static final String CREATE_BDD_PRISES = "CREATE TABLE " + TABLE_PRISES + " ("
  42 + + COL_ID_P + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_MEDOC + " TEXT NOT NULL, "
  43 + + COL_HEURE + " TEXT NOT NULL, " + COL_BOOL + " TEXT NOT NULL);";
  44 +
  45 + private static final String CREATE_BDD_MEDOCS = "CREATE TABLE " + TABLE_MEDOCS + " ("
  46 + + COL_ID_M + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_NOM1 + " TEXT NOT NULL, "
  47 + + COL_NOM2 + " TEXT NOT NULL, " + COL_POSO + " TEXT NOT NULL, " + COL_INFOS + " TEXT NOT NULL, "
  48 + + COL_LOGO + " TEXT NOT NULL);";
  49 +
  50 + public static synchronized StringSQLite getInstance(Context context){
  51 + if(sInstance == null){sInstance = new StringSQLite(context);}
  52 + return sInstance;
  53 + }
  54 +
  55 + public StringSQLite(Context context){
  56 + super(context, NOM_BDD, null, VERSION_BDD);
  57 + }
  58 +
  59 + @Override
  60 + public void onCreate(SQLiteDatabase db) {
  61 + //on crée la table à partir de la requête écrite dans la variable CREATE_BDD
  62 + db.execSQL(CREATE_BDD);
  63 + db.execSQL(CREATE_BDD_PRISES);
  64 + db.execSQL(CREATE_BDD_MEDOCS);
  65 + }
  66 +
  67 + @Override
  68 + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  69 + //On supprime la table puis la recrée afin de faire repartir les id à 0
  70 + db.execSQL("DROP TABLE " + TABLE_EVENTS + ";");
  71 + db.execSQL("DROP TABLE " + TABLE_PRISES + ";");
  72 + db.execSQL("DROP TABLE " + TABLE_MEDOCS + ";");
  73 + onCreate(db);
  74 + }
  75 +}
0 76 \ No newline at end of file
... ...
partieAndroid/res/drawable/checked.png 0 → 100644

15.7 KB

partieAndroid/res/drawable/delete.png 0 → 100644

14.3 KB

partieAndroid/res/drawable/dl.png 0 → 100644

1.56 KB

partieAndroid/res/drawable/edit.png 0 → 100644

11.4 KB

partieAndroid/res/drawable/gelules.png 0 → 100644

111 KB

partieAndroid/res/drawable/info.png 0 → 100644

24.4 KB

partieAndroid/res/drawable/next.png 0 → 100644

6.68 KB

partieAndroid/res/drawable/pill.png 0 → 100644

164 KB

partieAndroid/res/drawable/pills.png 0 → 100644

272 KB

partieAndroid/res/drawable/plus.png 0 → 100644

25.4 KB

partieAndroid/res/drawable/schedule.png 0 → 100644

10.6 KB

partieAndroid/res/drawable/vomi.png 0 → 100644

20.3 KB

partieAndroid/res/layout/activity_main.xml 0 → 100644
  1 +++ a/partieAndroid/res/layout/activity_main.xml
... ... @@ -0,0 +1,83 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:id="@+id/layoutMain"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="match_parent">
  6 +
  7 + <ImageButton
  8 + android:layout_width="50dp"
  9 + android:layout_height="50dp"
  10 + android:id="@+id/download"
  11 + android:adjustViewBounds="true"
  12 + android:src="@drawable/dl"
  13 + android:background="@color/colorPrimary"
  14 + android:scaleType="fitCenter"
  15 + android:layout_alignParentLeft="true"
  16 + android:onClick="onClickDownload"/>
  17 +
  18 + <ImageButton
  19 + android:layout_width="50dp"
  20 + android:layout_height="50dp"
  21 + android:layout_alignParentRight="true"
  22 + android:src="@drawable/vomi"
  23 + android:adjustViewBounds="true"
  24 + android:background="@color/colorPrimary"
  25 + android:scaleType="fitCenter"
  26 + android:onClick="onClickVomi"/>
  27 +
  28 + <TextView
  29 + android:id="@+id/text1"
  30 + android:layout_width="match_parent"
  31 + android:layout_below="@id/download"
  32 + android:layout_height="wrap_content"
  33 + android:text="@string/menu1"
  34 + android:textSize="25dp"
  35 + android:layout_marginBottom="5dp"
  36 + android:textColor="@color/colorAccent"/>
  37 +
  38 + <TextView
  39 + android:layout_width="match_parent"
  40 + android:layout_height="wrap_content"
  41 + android:id="@+id/présence"
  42 + android:textColor="@color/colorAccent"
  43 + android:layout_below="@+id/text1"/>
  44 +
  45 + <ListView
  46 + android:layout_width="match_parent"
  47 + android:layout_height="wrap_content"
  48 + android:id="@+id/list1"
  49 + android:layout_below="@+id/text1"
  50 + android:layout_above="@+id/layout1_1"/>
  51 +
  52 + <LinearLayout
  53 + android:id="@+id/layout1_1"
  54 + android:layout_width="match_parent"
  55 + android:layout_height="160dp"
  56 + android:layout_alignParentBottom="true"
  57 + android:layout_margin="2dp"
  58 + android:orientation="horizontal">
  59 +
  60 + <ImageButton
  61 + android:id="@+id/boutonMedoc"
  62 + android:layout_width="match_parent"
  63 + android:layout_height="match_parent"
  64 + android:layout_weight="1"
  65 + android:adjustViewBounds="true"
  66 + android:background="@color/colorPrimaryDark"
  67 + android:scaleType="fitCenter"
  68 + android:src="@drawable/pills"
  69 + android:onClick="onClickGestionMedoc"/>
  70 +
  71 + <ImageButton
  72 + android:id="@+id/boutonHistorique"
  73 + android:layout_width="match_parent"
  74 + android:layout_height="match_parent"
  75 + android:layout_marginLeft="5dp"
  76 + android:layout_weight="1"
  77 + android:onClick="onClickHistorique"
  78 + android:adjustViewBounds="true"
  79 + android:background="@color/colorPrimaryDark"
  80 + android:scaleType="fitCenter"
  81 + android:src="@drawable/schedule" />
  82 + </LinearLayout>
  83 +</RelativeLayout>
0 84 \ No newline at end of file
... ...
partieAndroid/res/layout/ajout_layout.xml 0 → 100644
  1 +++ a/partieAndroid/res/layout/ajout_layout.xml
... ... @@ -0,0 +1,25 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:orientation="vertical" android:layout_width="match_parent"
  4 + android:layout_height="match_parent">
  5 +
  6 + <AutoCompleteTextView
  7 + android:layout_width="match_parent"
  8 + android:layout_height="wrap_content"
  9 + android:textSize="20dp"
  10 + android:layout_margin="3dp"
  11 + android:id="@+id/textNom"
  12 + android:hint="@string/ajout1"/>
  13 +
  14 + <ImageButton
  15 + android:layout_width="40dp"
  16 + android:layout_height="40dp"
  17 + android:layout_margin="5dp"
  18 + android:layout_gravity="right"
  19 + android:src="@drawable/next"
  20 + android:adjustViewBounds="true"
  21 + android:background="@color/colorPrimary"
  22 + android:scaleType="fitCenter"
  23 + android:onClick="onClickAjout"/>
  24 +
  25 +</LinearLayout>
0 26 \ No newline at end of file
... ...
partieAndroid/res/layout/dialogue_prise.xml 0 → 100644
  1 +++ a/partieAndroid/res/layout/dialogue_prise.xml
... ... @@ -0,0 +1,31 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent" android:layout_height="match_parent">
  4 +
  5 + <EditText
  6 + android:layout_width="wrap_content"
  7 + android:layout_height="wrap_content"
  8 + android:text="00"
  9 + android:id="@+id/pick1"
  10 + android:textSize="30dp"
  11 + android:inputType="number"/>
  12 +
  13 + <TextView
  14 + android:layout_width="wrap_content"
  15 + android:layout_height="wrap_content"
  16 + android:textSize="20dp"
  17 + android:textColor="@color/colorAccent"
  18 + android:id="@+id/deuxPoints"
  19 + android:text="h"
  20 + android:layout_toRightOf="@+id/pick1"
  21 + android:layout_centerVertical="true"/>
  22 +
  23 + <EditText
  24 + android:layout_width="wrap_content"
  25 + android:layout_height="wrap_content"
  26 + android:layout_toRightOf="@+id/deuxPoints"
  27 + android:text="00"
  28 + android:id="@+id/pick2"
  29 + android:textSize="30dp"
  30 + android:inputType="number"/>
  31 +</RelativeLayout>
0 32 \ No newline at end of file
... ...
partieAndroid/res/layout/event.xml 0 → 100644
  1 +++ a/partieAndroid/res/layout/event.xml
... ... @@ -0,0 +1,21 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:orientation="vertical" android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + android:id="@+id/layoutEvent">
  6 +
  7 + <TextView
  8 + android:layout_width="match_parent"
  9 + android:layout_height="wrap_content"
  10 + android:id="@+id/date"
  11 + android:textSize="20sp"
  12 + android:textColor="@color/colorAccent" />
  13 +
  14 + <TextView
  15 + android:layout_width="match_parent"
  16 + android:layout_height="wrap_content"
  17 + android:id="@+id/event"
  18 + android:textSize="17sp"
  19 + android:textColor="@color/colorAccent" />
  20 +
  21 +</LinearLayout>
0 22 \ No newline at end of file
... ...
partieAndroid/res/layout/gestion_layout.xml 0 → 100644
  1 +++ a/partieAndroid/res/layout/gestion_layout.xml
... ... @@ -0,0 +1,41 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:orientation="vertical" android:layout_width="match_parent"
  4 + android:layout_height="match_parent">
  5 +
  6 + <TextView
  7 + android:layout_width="match_parent"
  8 + android:layout_height="wrap_content"
  9 + android:id="@+id/textListeMedoc"
  10 + android:text="@string/gestion1"
  11 + android:textSize="25dp"
  12 + android:textColor="@color/colorAccent" />
  13 +
  14 + <TextView
  15 + android:layout_width="match_parent"
  16 + android:layout_height="wrap_content"
  17 + android:id="@+id/aucunMedoc"
  18 + android:textColor="@color/colorAccent"
  19 + android:layout_below="@+id/textListeMedoc"/>
  20 +
  21 + <ListView
  22 + android:layout_width="match_parent"
  23 + android:layout_height="wrap_content"
  24 + android:id="@+id/listMedoc"
  25 + android:layout_below="@+id/textListeMedoc"
  26 + android:layout_above="@+id/buttonAjoutMedoc"/>
  27 +
  28 + <ImageButton
  29 + android:layout_width="60dp"
  30 + android:layout_height="60dp"
  31 + android:id="@+id/buttonAjoutMedoc"
  32 + android:src="@drawable/plus"
  33 + android:adjustViewBounds="true"
  34 + android:scaleType="fitCenter"
  35 + android:layout_alignParentRight="true"
  36 + android:layout_alignParentBottom="true"
  37 + android:layout_margin="3dp"
  38 + android:onClick="onClickAjoutMedoc"
  39 + android:background="@color/colorPrimary"/>
  40 +
  41 +</RelativeLayout>
0 42 \ No newline at end of file
... ...
partieAndroid/res/layout/historique_layout.xml 0 → 100644
  1 +++ a/partieAndroid/res/layout/historique_layout.xml
... ... @@ -0,0 +1,20 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:orientation="vertical"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="match_parent"
  6 + android:id="@+id/layoutHistorique">
  7 +
  8 + <TextView
  9 + android:layout_width="match_parent"
  10 + android:layout_height="wrap_content"
  11 + android:text="@string/historique1"
  12 + android:textColor="@color/colorAccent"
  13 + android:textSize="20dp"/>
  14 +
  15 + <ListView
  16 + android:layout_width="match_parent"
  17 + android:layout_height="wrap_content"
  18 + android:id="@+id/list2" />
  19 +
  20 +</LinearLayout>
0 21 \ No newline at end of file
... ...
partieAndroid/res/layout/medoc.xml 0 → 100644
  1 +++ a/partieAndroid/res/layout/medoc.xml
... ... @@ -0,0 +1,50 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent" android:layout_height="match_parent"
  4 + android:id="@+id/layoutMedoc">
  5 +
  6 + <ImageView
  7 + android:layout_width="100dp"
  8 + android:layout_height="100dp"
  9 + android:id="@+id/logo"
  10 + android:adjustViewBounds="true"
  11 + android:background="@color/colorPrimaryDark"
  12 + android:scaleType="fitCenter"
  13 + android:layout_alignParentLeft="true"
  14 + android:layout_alignParentStart="true"/>
  15 +
  16 + <TextView
  17 + android:layout_width="wrap_content"
  18 + android:layout_height="wrap_content"
  19 + android:id="@+id/nom1"
  20 + android:layout_toRightOf="@id/logo"
  21 + android:layout_alignTop="@id/logo"
  22 + android:textSize="25dp"
  23 + android:layout_marginLeft="5dp"
  24 + android:textColor="@color/colorAccent"/>
  25 +
  26 + <TextView
  27 + android:layout_width="wrap_content"
  28 + android:layout_height="wrap_content"
  29 + android:id="@+id/nom2"
  30 + android:layout_below="@id/nom1"
  31 + android:textSize="20dp"
  32 + android:layout_alignBottom="@id/logo"
  33 + android:layout_toRightOf="@id/logo"
  34 + android:layout_marginLeft="5dp"/>
  35 +
  36 + <ImageButton
  37 + android:layout_width="40dp"
  38 + android:layout_height="40dp"
  39 + android:id="@+id/boutonModif"
  40 + android:gravity="center_horizontal"
  41 + android:checked="false"
  42 + android:src="@drawable/edit"
  43 + android:adjustViewBounds="true"
  44 + android:background="@color/colorPrimary"
  45 + android:scaleType="fitCenter"
  46 + android:layout_below="@+id/nom1"
  47 + android:layout_alignParentRight="true"
  48 + android:layout_alignParentEnd="true" />
  49 +
  50 +</RelativeLayout>
0 51 \ No newline at end of file
... ...
partieAndroid/res/layout/modif_layout.xml 0 → 100644
  1 +++ a/partieAndroid/res/layout/modif_layout.xml
... ... @@ -0,0 +1,92 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent" android:layout_height="match_parent"
  4 + android:id="@+id/modif_layout">
  5 +
  6 + <ImageView
  7 + android:layout_width="100dp"
  8 + android:layout_height="100dp"
  9 + android:id="@+id/logo"
  10 + android:adjustViewBounds="true"
  11 + android:background="@color/colorPrimaryDark"
  12 + android:scaleType="fitCenter"
  13 + android:layout_alignParentLeft="true"
  14 + android:layout_alignParentStart="true"/>
  15 +
  16 + <TextView
  17 + android:layout_width="wrap_content"
  18 + android:layout_height="wrap_content"
  19 + android:id="@+id/nom1"
  20 + android:layout_toRightOf="@id/logo"
  21 + android:layout_alignTop="@id/logo"
  22 + android:textSize="25dp"
  23 + android:layout_marginLeft="5dp"
  24 + android:textColor="@color/colorAccent"/>
  25 +
  26 + <TextView
  27 + android:layout_width="wrap_content"
  28 + android:layout_height="wrap_content"
  29 + android:id="@+id/nom2"
  30 + android:layout_below="@id/nom1"
  31 + android:textSize="20dp"
  32 + android:layout_alignBottom="@id/logo"
  33 + android:layout_toRightOf="@id/logo"
  34 + android:layout_marginLeft="5dp"/>
  35 +
  36 + <ImageButton
  37 + android:layout_width="50dp"
  38 + android:layout_height="50dp"
  39 + android:id="@+id/infoMedoc"
  40 + android:layout_alignParentRight="true"
  41 + android:layout_below="@+id/nom2"
  42 + android:src="@drawable/info"
  43 + android:adjustViewBounds="true"
  44 + android:background="@color/colorPrimary"
  45 + android:scaleType="fitCenter"
  46 + android:onClick="onClickInfos"/>
  47 +
  48 + <ListView
  49 + android:layout_width="match_parent"
  50 + android:layout_height="wrap_content"
  51 + android:id="@+id/listePrises"
  52 + android:layout_below="@+id/texte"/>
  53 +
  54 + <ImageButton
  55 + android:layout_width="60dp"
  56 + android:layout_height="60dp"
  57 + android:id="@+id/buttonChecked"
  58 + android:src="@drawable/checked"
  59 + android:adjustViewBounds="true"
  60 + android:scaleType="fitCenter"
  61 + android:background="@color/colorPrimary"
  62 + android:onClick="onClickRetour"
  63 + android:layout_marginBottom="10dp"
  64 + android:layout_alignParentBottom="true"
  65 + android:layout_alignParentRight="true" />
  66 +
  67 + <TextView
  68 + android:layout_width="wrap_content"
  69 + android:layout_height="wrap_content"
  70 + android:id="@+id/texte"
  71 + android:textSize="20dp"
  72 + android:textColor="@color/colorAccent"
  73 + android:text="@string/modif1"
  74 + android:layout_alignBottom="@+id/infoMedoc"
  75 + android:layout_alignParentLeft="true"
  76 + android:layout_alignParentStart="true" />
  77 +
  78 + <ImageButton
  79 + android:layout_width="60dp"
  80 + android:layout_height="60dp"
  81 + android:id="@+id/buttonAjoutPrise"
  82 + android:src="@drawable/plus"
  83 + android:adjustViewBounds="true"
  84 + android:scaleType="fitCenter"
  85 + android:background="@color/colorPrimary"
  86 + android:onClick="onClickAjoutPrise"
  87 + android:layout_above="@+id/buttonChecked"
  88 + android:layout_alignParentRight="true"
  89 + android:layout_alignParentEnd="true"
  90 + android:layout_marginBottom="10dp"/>
  91 +
  92 +</RelativeLayout>
0 93 \ No newline at end of file
... ...
partieAndroid/res/layout/prise_medoc.xml 0 → 100644
  1 +++ a/partieAndroid/res/layout/prise_medoc.xml
... ... @@ -0,0 +1,30 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +
  3 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="wrap_content"
  6 + android:id="@+id/layoutPrise">
  7 +
  8 + <TextView
  9 + android:layout_width="wrap_content"
  10 + android:layout_height="wrap_content"
  11 + android:id="@+id/horloge"
  12 + android:textSize="40dp"
  13 + android:layout_marginLeft="30dp"
  14 + android:layout_marginRight="5dp"
  15 + android:gravity="center_horizontal"/>
  16 +
  17 + <ImageButton
  18 + android:layout_width="30dp"
  19 + android:layout_height="30dp"
  20 + android:id="@+id/boutonConfirm"
  21 + android:gravity="end"
  22 + android:checked="false"
  23 + android:adjustViewBounds="true"
  24 + android:background="@color/colorPrimary"
  25 + android:scaleType="fitCenter"
  26 + android:layout_alignBottom="@+id/horloge"
  27 + android:layout_toRightOf="@+id/horloge"
  28 + android:layout_toEndOf="@+id/horloge" />
  29 +
  30 +</RelativeLayout>
0 31 \ No newline at end of file
... ...
partieAndroid/res/layout/prise_menu.xml 0 → 100644
  1 +++ a/partieAndroid/res/layout/prise_menu.xml
... ... @@ -0,0 +1,52 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +
  3 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="wrap_content"
  6 + android:id="@+id/layoutPrise">
  7 +
  8 + <ImageView
  9 + android:layout_width="80dp"
  10 + android:layout_height="80dp"
  11 + android:id="@+id/logoMenu"
  12 + android:layout_margin="5dp"
  13 + android:adjustViewBounds="true"
  14 + android:background="@color/colorPrimaryDark"
  15 + android:scaleType="fitCenter"
  16 + android:layout_alignParentLeft="true"
  17 + android:layout_alignParentStart="true"/>
  18 +
  19 + <ImageButton
  20 + android:layout_width="40dp"
  21 + android:layout_height="40dp"
  22 + android:id="@+id/boutonConfirmMenu"
  23 + android:gravity="end"
  24 + android:checked="false"
  25 + android:adjustViewBounds="true"
  26 + android:background="@color/colorPrimary"
  27 + android:scaleType="fitCenter"
  28 + android:layout_marginRight="15dp"
  29 + android:layout_centerVertical="true"
  30 + android:layout_alignParentRight="true"/>
  31 +
  32 + <TextView
  33 + android:layout_width="wrap_content"
  34 + android:layout_height="wrap_content"
  35 + android:id="@+id/horlogeMenu"
  36 + android:textSize="25dp"
  37 + android:gravity="center_horizontal"
  38 + android:layout_below="@+id/nomMenu"
  39 + android:layout_toRightOf="@+id/logoMenu"
  40 + android:layout_toEndOf="@+id/logoMenu" />
  41 +
  42 + <TextView
  43 + android:layout_width="wrap_content"
  44 + android:layout_height="wrap_content"
  45 + android:id="@+id/nomMenu"
  46 + android:textSize="30dp"
  47 + android:gravity="center_horizontal"
  48 + android:layout_alignParentTop="true"
  49 + android:layout_toRightOf="@+id/logoMenu"
  50 + android:layout_toEndOf="@+id/logoMenu" />
  51 +
  52 +</RelativeLayout>
0 53 \ No newline at end of file
... ...
partieAndroid/res/mipmap-hdpi/ic_launcher.png 0 → 100644

3.34 KB

partieAndroid/res/mipmap-mdpi/ic_launcher.png 0 → 100644

2.15 KB

partieAndroid/res/mipmap-xhdpi/ic_launcher.png 0 → 100644

4.73 KB

partieAndroid/res/mipmap-xxhdpi/ic_launcher.png 0 → 100644

7.54 KB

partieAndroid/res/mipmap-xxxhdpi/ic_launcher.png 0 → 100644

10.2 KB

partieAndroid/res/values-fr/strings.xml 0 → 100644
  1 +++ a/partieAndroid/res/values-fr/strings.xml
... ... @@ -0,0 +1,42 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <string name="app_name">Tech\' Your Pill</string>
  4 +
  5 + <string name="oui">OUI</string>
  6 + <string name="non">NON</string>
  7 + <string name="ok">OK</string>
  8 + <string name="annuler">ANNULER</string>
  9 + <string name="enregistrer">ENREGISTRER</string>
  10 +
  11 + <string name="menu1">Vos prises du moment :</string>
  12 + <string name="menu2">Vous n\'avez aucun médicament à prendre pour le moment.</string>
  13 + <string name="menu3">CONFIRMATION</string>
  14 + <string name="menu4">Confirmation de la prise de </string>
  15 + <string name="menu5">Une erreur est survenue. Vérifiez votre accès à internet.</string>
  16 + <string name="menu6">La prise a été enregistrée.</string>
  17 + <string name="menu7">pris à </string>
  18 + <string name="menu8">Avez-vous été pris de vomissements ?</string>
  19 + <string name="menu9">Vomissements subis vers</string>
  20 + <string name="menu10">Fin du téléchargement.</string>
  21 +
  22 + <string name="historique1">Historique de vos prises :</string>
  23 +
  24 + <string name="gestion1">Liste de vos médicaments :</string>
  25 + <string name="gestion2">Vous ne prenez actuellement aucun médicament.</string>
  26 +
  27 + <string name="ajout1">Nom du médicament</string>
  28 + <string name="ajout2">Nom incorrect.</string>
  29 + <string name="ajout3">Vous prenez déjà ce médicament.</string>
  30 +
  31 + <string name="modif1">Quand prendre ce médicament ?</string>
  32 + <string name="modif2">Nom du médicament :</string>
  33 + <string name="modif3">Nom de la molécule :</string>
  34 + <string name="modif4">Posologie :</string>
  35 + <string name="modif5">Indications :</string>
  36 + <string name="modif6">Heure de la prise :</string>
  37 + <string name="modif7">(dans la même forme que l\'exemple)</string>
  38 + <string name="modif8">Supprimer la prise ?</string>
  39 + <string name="modif9">Heure incorrecte.</string>
  40 +
  41 + <string name="notif1">Il est l\'heure de prendre vos cachets !</string>
  42 +</resources>
0 43 \ No newline at end of file
... ...
partieAndroid/res/values-w820dp/dimens.xml 0 → 100644
  1 +++ a/partieAndroid/res/values-w820dp/dimens.xml
... ... @@ -0,0 +1,6 @@
  1 +<resources>
  2 + <!-- Example customization of dimensions originally defined in res/values/dimens.xml
  3 + (such as screen margins) for screens with more than 820dp of available width. This
  4 + would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
  5 + <dimen name="activity_horizontal_margin">64dp</dimen>
  6 +</resources>
... ...
partieAndroid/res/values/colors.xml 0 → 100644
  1 +++ a/partieAndroid/res/values/colors.xml
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <color name="colorPrimary">#f1fdff</color>
  4 + <color name="colorPrimaryDark">#90daf1</color>
  5 + <color name="colorAccent">#1a2163</color>
  6 +</resources>
... ...
partieAndroid/res/values/dimens.xml 0 → 100644
  1 +++ a/partieAndroid/res/values/dimens.xml
... ... @@ -0,0 +1,5 @@
  1 +<resources>
  2 + <!-- Default screen margins, per the Android Design guidelines. -->
  3 + <dimen name="activity_horizontal_margin">16dp</dimen>
  4 + <dimen name="activity_vertical_margin">16dp</dimen>
  5 +</resources>
... ...
partieAndroid/res/values/strings.xml 0 → 100644
  1 +++ a/partieAndroid/res/values/strings.xml
... ... @@ -0,0 +1,41 @@
  1 +<resources>
  2 + <string name="app_name">Tech\' Your Pill</string>
  3 +
  4 + <string name="oui">YES</string>
  5 + <string name="non">NO</string>
  6 + <string name="ok">OK</string>
  7 + <string name="annuler">CANCEL</string>
  8 + <string name="enregistrer">RECORD</string>
  9 +
  10 + <string name="menu1">What you should take now:</string>
  11 + <string name="menu2">Nothing to be taken now.</string>
  12 + <string name="menu3">Do you confirm...</string>
  13 + <string name="menu4">Are you just taking </string>
  14 + <string name="menu5">An error has occurred. Check your internet access.</string>
  15 + <string name="menu6">Your medication has been recorded.</string>
  16 + <string name="menu7">taken at</string>
  17 + <string name="menu8">Have you been vomiting ?</string>
  18 + <string name="menu9">Vomiting at around</string>
  19 + <string name="menu10">Download completed.</string>
  20 +
  21 + <string name="historique1">Your medication history:</string>
  22 +
  23 + <string name="gestion1">Your medicine list:</string>
  24 + <string name="gestion2">You are not taking any medicine.</string>
  25 +
  26 + <string name="ajout1">Medicine name</string>
  27 + <string name="ajout2">Invalid name.</string>
  28 + <string name="ajout3">You are already taking this medicine.</string>
  29 +
  30 + <string name="modif1">When should I take it ?</string>
  31 + <string name="modif2">Medicine name:</string>
  32 + <string name="modif3">Molecule name:</string>
  33 + <string name="modif4">Dosage:</string>
  34 + <string name="modif5">Further information</string>
  35 + <string name="modif6">Add a new schedule:</string>
  36 + <string name="modif7">(as shown in the example)</string>
  37 + <string name="modif8">Delete this scheduled hour?</string>
  38 + <string name="modif9">Invalid hour.</string>
  39 +
  40 + <string name="notif1">It is time to take your medication !</string>
  41 +</resources>
... ...
partieAndroid/res/values/styles.xml 0 → 100644
  1 +++ a/partieAndroid/res/values/styles.xml
... ... @@ -0,0 +1,12 @@
  1 +<resources>
  2 +
  3 + <!-- Base application theme. -->
  4 + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  5 + <!-- Customize your theme here. -->
  6 + <item name="colorPrimary">@color/colorPrimary</item>
  7 + <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
  8 + <item name="colorAccent">@color/colorAccent</item>
  9 + <item name="android:colorBackground">@color/background_material_light</item>
  10 + </style>
  11 +
  12 +</resources>
... ...
partieAndroid/res/values/values.xml 0 → 100644
  1 +++ a/partieAndroid/res/values/values.xml
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <color name="background_material_light">@color/colorPrimary</color>
  4 + <color name="primary_text_default_material_dark">@color/colorPrimaryDark</color>
  5 + <color name="primary_text_default_material_light">@color/colorAccent</color>
  6 +</resources>
0 7 \ No newline at end of file
... ...
partieWeb/add_medoc.php 0 → 100644
  1 +++ a/partieWeb/add_medoc.php
... ... @@ -0,0 +1,24 @@
  1 +<HTML>
  2 +<HEAD><link rel="stylesheet" type="text/css" href="page.css">
  3 +</HEAD>
  4 +<BODY>
  5 +<div id="container1">
  6 +<form enctype ="multipart/form-data" action ="upload_image.php" method="POST">
  7 + <p>Nom du médicament :</p>
  8 + <input type="text" name="nom_medoc" value="<?php if (isset($_POST['nom_medoc'])){echo $_POST['nom_medoc'];}?>"/>
  9 + <p> Nom molécule : </p>
  10 + <input type="text" name="molecule" value="<?php if (isset($_POST['molecule'])){echo $_POST['molecule'];}?>"/>
  11 + <p> Photo du medicament :</p>
  12 + <input type="file" name="photo">
  13 + <input type="hidden" name="MAX_FILE_SIZE" value="30000" /><br>
  14 + <p> Posologie : </p>
  15 + <input type="text" name="posologie" value="<?php if (isset($_POST['posologie'])){echo $_POST['posologie'];}?>"/>
  16 +<br/>
  17 + <p> Indications : </p>
  18 + <textarea name="indic" rows="8" cols="45"></textarea></br>
  19 +
  20 +<input type="submit" value="valider" name="valider"/>
  21 +
  22 +</form>
  23 +</BODY>
  24 +</HTML>
0 25 \ No newline at end of file
... ...
partieWeb/aspirine.html 0 → 100644
  1 +++ a/partieWeb/aspirine.html
... ... @@ -0,0 +1,10 @@
  1 +<HTML><br>
  2 +<HEAD><link rel=stylesheet type=text/css href=page.css></HEAD><br>
  3 +<BODY><br>
  4 +<div id=container><br>
  5 +<div id=header>
  6 +<h1>Site internet du CHR de Lille</h1></div><br>
  7 +<div id=menu><h2>Menu</h2><ul><li><a href=./menu.php>Retour au menu</a></li></ul></div><div id=contents><a name=content></a><h2>aspirine(acide acetylsalicylique)</h2>
  8 +<p><img class=imagefloat src=./aspirine.jpg alt=aspirine width=150 height=150 /></p><br/><a name=content></a><h2>Posologie</h2>3 a 4 fois par jour <a name=content></a><h2>Indications</h2>Indications de tout types Indications de tout types Indications de tout types Indications de tout types Indications de tout types Indications de tout types Indications de tout types Indications de tout types Indications de tout types Indications de tout types Indications de tout types Indications de tout types Indications de tout types </form>
  9 +</BODY>
  10 +</HTML></div></div></BODY></HTML>
0 11 \ No newline at end of file
... ...
partieWeb/aspirine.jpg 0 → 100644

14 KB

partieWeb/liste_fiche.php 0 → 100644
  1 +++ a/partieWeb/liste_fiche.php
... ... @@ -0,0 +1,25 @@
  1 +<HTML>
  2 +<HEAD><link rel="stylesheet" type="text/css" href="page.css"></HEAD>
  3 +<BODY>
  4 +<div id="container">
  5 +<?php
  6 +echo '<ul>';
  7 +if($dossier = opendir('.'))
  8 +{
  9 +while(false !==($fichier = readdir($dossier)))
  10 +{
  11 + if($fichier != '.' && $fichier != '..' && preg_match('/html/i',$fichier))
  12 + {
  13 + echo '<li><a href="./' . $fichier. '">' . $fichier . '</a></li>';
  14 + }
  15 +}
  16 +closedir($dossier);
  17 +}
  18 +else
  19 + echo 'le dossier n\' a pas pu être ouvert';
  20 +$bug='.html';
  21 + if(file_exists($bug))
  22 + unlink( $bug ) ;
  23 +?>
  24 +</BODY>
  25 +</HTML>
0 26 \ No newline at end of file
... ...
partieWeb/menu.php 0 → 100644
  1 +++ a/partieWeb/menu.php
... ... @@ -0,0 +1,20 @@
  1 +<HTML>
  2 +<HEAD><link rel="stylesheet" type="text/css" href="page.css"></HEAD>
  3 +<BODY>
  4 +<div id="container1">
  5 +<h2>Menu</h2>
  6 +<form method="post">
  7 +<input type="submit" name="Addfiche" value="Ajouter une fiche"/><br/><br/>
  8 +<input type="submit" name="Seefiche" value="Voir mes fiches"/><br/><br/>
  9 +</form></div>
  10 +</BODY>
  11 +</HTML>
  12 +<?php
  13 +if(isset($_POST['Addfiche']))
  14 +header('location:./add_medoc.php');
  15 +elseif(isset($_POST['Seefiche']))
  16 +header('location:./liste_fiche.php');
  17 +?>
  18 +
  19 +
  20 +
... ...
partieWeb/page.css 0 → 100644
  1 +++ a/partieWeb/page.css
... ... @@ -0,0 +1,94 @@
  1 +#container
  2 + {
  3 + margin: 1em auto;
  4 + width: 650px;
  5 + text-align:left;
  6 + background-color:#F7F2E0;
  7 + border: 1px solid #676767;
  8 + }
  9 +#container1
  10 + {
  11 + margin: 1em auto;
  12 + width: 650px;
  13 + text-align:center;
  14 + background-color:#F7F2E0;
  15 + border: 1px solid #676767;
  16 + }
  17 +#header
  18 + {
  19 + height: 53px;
  20 + background-image: url(header.jpg);
  21 + background-repeat: no-repeat;
  22 + background-position: 0 0;
  23 + border-bottom: 1px solid #fff;
  24 + position: relative;
  25 + }
  26 + #header2
  27 + {
  28 + height: 53px;
  29 + text-align:center;
  30 + background-image: url(header.jpg);
  31 + background-repeat: no-repeat;
  32 + background-position: 0 0;
  33 + border-bottom: 1px solid #fff;
  34 + position: relative;
  35 + }
  36 + #mainnav
  37 + {
  38 + background-color: #0EFCEA;
  39 + color: #272900;
  40 + padding: 2px 0;
  41 + margin: 0 0 20px 0;
  42 + }
  43 + #skipmenu
  44 + {
  45 + position: absolute;
  46 + right: 10px;
  47 + top: 5px;
  48 + }
  49 + #skipmenu a
  50 + {
  51 + color: #555;
  52 + text-decoration: none;
  53 + }
  54 + #skipmenu a:hover
  55 + {
  56 + color: #fff;
  57 + background-color:#F7F693;
  58 + text-decoration: none;
  59 + }
  60 +#menu
  61 + {
  62 + float: right;
  63 + width: 150px;
  64 + }
  65 +#menu ul
  66 + {
  67 + margin-left: 0;
  68 + padding-left: 0;
  69 + list-style-type: none;
  70 + line-height: 165%;
  71 + }
  72 + #contents
  73 + {
  74 + margin: 0 170px 40px 20px;
  75 + border-right: 1px solid #C5C877;
  76 + padding-right: 20px;
  77 + }
  78 + #contents p { line-height: 165%; }
  79 + .imagefloat
  80 + {
  81 + float: right;
  82 + padding: 2px;
  83 + border: 1px solid #9FA41D;
  84 + margin: 0 0 10px 10px;
  85 + }
  86 + #footer
  87 + {
  88 + clear: both;
  89 + color: #272900;
  90 + background-color: #35F1CF;
  91 + text-align: right;
  92 + padding: 5px;
  93 + font-size: 90%;
  94 + }
... ...
partieWeb/public/page.css 0 → 100644
  1 +++ a/partieWeb/public/page.css
... ... @@ -0,0 +1,94 @@
  1 +#container
  2 + {
  3 + margin: 1em auto;
  4 + width: 650px;
  5 + text-align:left;
  6 + background-color:#F7F2E0;
  7 + border: 1px solid #676767;
  8 + }
  9 +#container1
  10 + {
  11 + margin: 1em auto;
  12 + width: 650px;
  13 + text-align:center;
  14 + background-color:#F7F2E0;
  15 + border: 1px solid #676767;
  16 + }
  17 +#header
  18 + {
  19 + height: 53px;
  20 + background-image: url(header.jpg);
  21 + background-repeat: no-repeat;
  22 + background-position: 0 0;
  23 + border-bottom: 1px solid #fff;
  24 + position: relative;
  25 + }
  26 + #header2
  27 + {
  28 + height: 53px;
  29 + text-align:center;
  30 + background-image: url(header.jpg);
  31 + background-repeat: no-repeat;
  32 + background-position: 0 0;
  33 + border-bottom: 1px solid #fff;
  34 + position: relative;
  35 + }
  36 + #mainnav
  37 + {
  38 + background-color: #0EFCEA;
  39 + color: #272900;
  40 + padding: 2px 0;
  41 + margin: 0 0 20px 0;
  42 + }
  43 + #skipmenu
  44 + {
  45 + position: absolute;
  46 + right: 10px;
  47 + top: 5px;
  48 + }
  49 + #skipmenu a
  50 + {
  51 + color: #555;
  52 + text-decoration: none;
  53 + }
  54 + #skipmenu a:hover
  55 + {
  56 + color: #fff;
  57 + background-color:#F7F693;
  58 + text-decoration: none;
  59 + }
  60 +#menu
  61 + {
  62 + float: right;
  63 + width: 150px;
  64 + }
  65 +#menu ul
  66 + {
  67 + margin-left: 0;
  68 + padding-left: 0;
  69 + list-style-type: none;
  70 + line-height: 165%;
  71 + }
  72 + #contents
  73 + {
  74 + margin: 0 170px 40px 20px;
  75 + border-right: 1px solid #C5C877;
  76 + padding-right: 20px;
  77 + }
  78 + #contents p { line-height: 165%; }
  79 + .imagefloat
  80 + {
  81 + float: right;
  82 + padding: 2px;
  83 + border: 1px solid #9FA41D;
  84 + margin: 0 0 10px 10px;
  85 + }
  86 + #footer
  87 + {
  88 + clear: both;
  89 + color: #272900;
  90 + background-color: #35F1CF;
  91 + text-align: right;
  92 + padding: 5px;
  93 + font-size: 90%;
  94 + }
... ...
partieWeb/upload_image.php 0 → 100644
  1 +++ a/partieWeb/upload_image.php
... ... @@ -0,0 +1,51 @@
  1 +<HTML>
  2 +<HEAD><link rel="stylesheet" type="text/css" href="page.css"></HEAD>
  3 +<BODY>
  4 +<div id="container">
  5 +<form enctype ="multipart/form-data" action ="menu.php" method="POST">
  6 +<?php
  7 +$uploaddir='/wamp/www/tests/private/';
  8 +$uploadfile= $uploaddir. basename($_FILES['photo']['name']);
  9 +echo '<pre>';
  10 +if (move_uploaded_file($_FILES['photo']['tmp_name'],$uploadfile))
  11 +{
  12 + echo"La fiche est valide et a été crée avec succés";
  13 +}
  14 +echo'</pre>';
  15 +$file = fopen($nom=$_POST['nom_medoc'].".html","w");
  16 +fwrite($file,"<HTML><br>");
  17 +fwrite($file,"\r\n");
  18 +fwrite($file,"<HEAD><link rel=stylesheet type=text/css href=page.css></HEAD><br>");
  19 +fwrite($file,"\r\n");
  20 +fwrite($file,"<BODY><br>");
  21 +fwrite($file,"\r\n");
  22 +fwrite($file,"<div id=container><br>");
  23 +fwrite($file,"\r\n");
  24 +fwrite($file,"<div id=header>");
  25 +fwrite($file,"\r\n");
  26 +fwrite($file,"<h1>Site internet du CHR de Lille</h1></div><br>");
  27 +fwrite($file,"\r\n");
  28 +fwrite($file,"<div id=menu><h2>Menu</h2><ul><li><a href=./menu.php>Retour au menu</a></li></ul></div>");
  29 +fwrite($file,"<div id=contents>");
  30 +fwrite($file,"<a name=content></a><h2>$_POST[nom_medoc]($_POST[molecule])</h2>");
  31 +fwrite($file,"\r\n");
  32 +fwrite($file,"<p><img class=imagefloat src=./$_POST[nom_medoc].jpg alt=$_POST[nom_medoc] width=150 height=150 /></p>");
  33 +fwrite($file,"<br/>");
  34 +fwrite($file,"<a name=content></a><h2>Posologie</h2>");
  35 +fwrite($file,"$_POST[posologie]");
  36 +fwrite($file,"<a name=content></a><h2>Indications</h2>");
  37 +fwrite($file,"$_POST[indic]</form>
  38 +</BODY>
  39 +</HTML>");
  40 +fwrite($file,"</div></div></BODY>");
  41 +fwrite ($file,"</HTML>");
  42 +fclose($file);
  43 +?>
  44 +<input type="submit" value="retour au menu" name="retour"/>
  45 +
  46 +<?php
  47 +if(isset($_POST['retour']))
  48 +header('location:./liste_fiche.php');
  49 +?>
  50 +</BODY>
  51 +</HTML>
0 52 \ No newline at end of file
... ...