diff --git a/app-release.apk b/app-release.apk new file mode 100644 index 0000000..1523b0a Binary files /dev/null and b/app-release.apk differ diff --git a/partieAndroid/AndroidManifest.xml b/partieAndroid/AndroidManifest.xml new file mode 100644 index 0000000..b2aab3c --- /dev/null +++ b/partieAndroid/AndroidManifest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/codesJava/AjoutMedocActivity.java b/partieAndroid/codesJava/AjoutMedocActivity.java new file mode 100644 index 0000000..2f5a77b --- /dev/null +++ b/partieAndroid/codesJava/AjoutMedocActivity.java @@ -0,0 +1,96 @@ +package com.example.martin.projetv5; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.AutoCompleteTextView; +import android.widget.Toast; + +import java.util.ArrayList; + +/** + * Created by martin on 28/02/2017. + */ + +public class AjoutMedocActivity extends AppCompatActivity { + + StringBDD eventBDD = null; + ArrayList arrayList = new ArrayList<>(); + AutoCompleteTextView editNom = null; + + + public void onClickAjout(View view){ + editNom = (AutoCompleteTextView) findViewById(R.id.textNom); + String s1 = editNom.getText().toString(); + + // on regarde si le nom rentré existe + boolean existe = false; + int w=1; + while(w <= eventBDD.getIndiceMaxMedoc() && !existe) { + Medicament m = eventBDD.getMedocWithId(w); + if (m.getNom1().equals(s1)) existe = true; + w++; + } + + if(existe) { + Medicament m = eventBDD.getMedocWithNom1(s1); + + // s'il existe on regarde ensuite si ce medicament n'est pas déjà en train d'être pris + boolean ok = true; + int x=1; + while(x <= eventBDD.getIndiceMaxPrise() && ok){ + Prise2 p = eventBDD.getPriseWithId(x); + if(p.getIdMedoc().equals(m.getIdM()))ok = false; + x++; + } + + if(ok) { + // si tout est bon, on poursuit + Intent i = new Intent(this, ModifMedocActivity.class); + boolean nouveau = true; + i.putExtra("id", m.getIdM()); + i.putExtra("new", nouveau); + startActivity(i); + } + else Toast.makeText(this,R.string.ajout3,Toast.LENGTH_LONG).show(); + } + else Toast.makeText(this,R.string.ajout2,Toast.LENGTH_LONG).show(); + } + + void recupNom1Medoc(ArrayList aList){ + for(int w=0; w adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, arrayList); + editNom.setAdapter(adapter); + editNom.setThreshold(0); + } + + @Override + protected void onPause() { + eventBDD.close(); + super.onPause(); + arrayList.clear(); + } +} diff --git a/partieAndroid/codesJava/Alarm.java b/partieAndroid/codesJava/Alarm.java new file mode 100644 index 0000000..974cc34 --- /dev/null +++ b/partieAndroid/codesJava/Alarm.java @@ -0,0 +1,55 @@ +package com.example.martin.projetv5; + +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.PowerManager; +import android.util.Log; + +import java.util.Calendar; + +/** + * Created by martin on 06/05/2017. + */ + + +public class Alarm extends BroadcastReceiver +{ + + @Override + public void onReceive(Context context, Intent intent) + { + PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, ""); + wl.acquire(); + Intent i = new Intent(context,AlarmeService.class); + context.startService(i); + wl.release(); + } + + public void setAlarm(Context context, String heure) + { + String[] s = heure.split("h"); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(s[0])); + calendar.set(Calendar.MINUTE, Integer.parseInt(s[1])); + long when = calendar.getTimeInMillis(); + + if(when < System.currentTimeMillis()) when += 24*60*60000; + + AlarmManager am =( AlarmManager)context.getSystemService(Context.ALARM_SERVICE); + Intent i = new Intent(context, Alarm.class); + PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0); + am.set(AlarmManager.RTC_WAKEUP, when, pi); + } + + public void cancelAlarm(Context context) + { + Intent intent = new Intent(context, Alarm.class); + PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0); + AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + alarmManager.cancel(sender); + } +} \ No newline at end of file diff --git a/partieAndroid/codesJava/AlarmeService.java b/partieAndroid/codesJava/AlarmeService.java new file mode 100644 index 0000000..ad9710b --- /dev/null +++ b/partieAndroid/codesJava/AlarmeService.java @@ -0,0 +1,57 @@ +package com.example.martin.projetv5; + +import android.app.IntentService; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.app.TaskStackBuilder; +import android.content.Context; +import android.content.Intent; +import android.os.Vibrator; + +import static android.app.Notification.FLAG_AUTO_CANCEL; + +/** + * Created by martin on 15/03/2017. + */ + +public class AlarmeService extends IntentService { + private final static String TAG ="IntentServiceExample"; + public int ID_NOTIFICATION = 0; + + public AlarmeService(){ + super(TAG); + } + + @Override + protected void onHandleIntent(Intent intent){ + int icon = R.drawable.pill; + long when = System.currentTimeMillis(); + + Vibrator vib = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); + long pattern[] = {0,400,200,400}; + vib.vibrate(pattern,-1); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(),0,intent,0); + + Notification.Builder builder = new Notification.Builder(getApplicationContext()) + .setWhen(when) + .setTicker(getString(R.string.notif1)) + .setSmallIcon(icon) + .setContentTitle("Tech' your pill") + .setContentText(getString(R.string.notif1)) + .setContentIntent(contentIntent); + + Intent resultIntent = new Intent(this,MainActivity.class); + + TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); + stackBuilder.addNextIntent(intent); + PendingIntent resultPendingIntent = PendingIntent.getActivity(this,0,resultIntent,PendingIntent.FLAG_UPDATE_CURRENT); + builder.setContentIntent(resultPendingIntent); + + NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + Notification notif = builder.build(); + notif.flags = FLAG_AUTO_CANCEL; + manager.notify(ID_NOTIFICATION,notif); + } +} diff --git a/partieAndroid/codesJava/AutoStart.java b/partieAndroid/codesJava/AutoStart.java new file mode 100644 index 0000000..3c4b7bf --- /dev/null +++ b/partieAndroid/codesJava/AutoStart.java @@ -0,0 +1,28 @@ +package com.example.martin.projetv5; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +/** + * Created by martin on 06/05/2017. + */ + +public class AutoStart extends BroadcastReceiver +{ + Alarm alarm = new Alarm(); + @Override + public void onReceive(Context context, Intent intent) + { + if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) + { + StringBDD eventBDD = new StringBDD(context); + eventBDD.open(); + for(int i = 0; i mList; + public Context mContext; + public LayoutInflater mInflater; + + public EventAdapter(Context context, List aList) { + mContext = context; + mList = aList; + mInflater = LayoutInflater.from(mContext); + } + + public int getCount() { + return mList.size(); + } + + public Object getItem(int position) { + return mList.get(position); + } + + public long getItemId(int position) { + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + LinearLayout layoutItem; + + if (convertView == null) { + layoutItem = (LinearLayout) mInflater.inflate(R.layout.event, parent, false); + } else { + layoutItem = (LinearLayout) convertView; + } + + TextView date = (TextView) layoutItem.findViewById(R.id.date); + TextView event = (TextView) layoutItem.findViewById(R.id.event); + + date.setText(mList.get(position).getDate()); + event.setText(mList.get(position).getEvenement()); + + return layoutItem; + } + + public interface EventAdapterListener { + void onClickButton(Event item, int position); + } + + private ArrayList mListListener = new ArrayList(); + + public void addListener(EventAdapterListener aListener) { + mListListener.add(aListener); + } +} \ No newline at end of file diff --git a/partieAndroid/codesJava/GestionActivity.java b/partieAndroid/codesJava/GestionActivity.java new file mode 100644 index 0000000..96ff4c4 --- /dev/null +++ b/partieAndroid/codesJava/GestionActivity.java @@ -0,0 +1,109 @@ +package com.example.martin.projetv5; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.ListView; +import android.widget.TextView; + +import java.util.ArrayList; + +/** + * Created by martin on 28/02/2017. + */ + +public class GestionActivity extends AppCompatActivity implements MedocAdapterMenu.MedocAdapterListener { + + ArrayList listMedocs = new ArrayList<>(); + MedocAdapterMenu adapter = null; + ListView list = null; + StringBDD eventBDD = null; + + void addElementList(Medicament m, ArrayList listM){ + listM.add(m); + adapter.notifyDataSetChanged(); + } + + void supList(ArrayList listM){ + listM.clear(); + adapter.notifyDataSetChanged(); + } + + public void onClickAjoutMedoc(View view){ + Intent i = new Intent(this, AjoutMedocActivity.class); + startActivity(i); + } + + public void gestionList(){ + boolean present = false; + for(int w=0; w listEvents = new ArrayList<>(); + EventAdapter adapter = null; + ListView list = null; + + Event[] tabEvents = null; + + StringBDD eventBDD = null; + + void addEventList(Event ev, ArrayList listP){ + listP.add(ev); + adapter.notifyDataSetChanged(); + } + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.historique_layout); + + adapter = new EventAdapter(this,listEvents); + adapter.addListener(this); + list = (ListView)findViewById(R.id.list2); + list.setAdapter(adapter); + + eventBDD = new StringBDD(this); + eventBDD.open(); + int indMax = eventBDD.getIndiceMaxEvent(); + tabEvents = new Event[indMax]; + + for(int j=0; j listPrises = new ArrayList<>(); + PriseAdapterMenu adapter = null; + ListView list = null; + + String res = ""; + + StringBDD eventBDD = null; + + String filepath=null; + boolean fini; + + public void gestionHeure(){ + supList(listPrises); + + long now = System.currentTimeMillis(); + int cpt = 0; + + for(int w=0; w= valeur2h+3600000*20){ + valeurDate -= 3600000*24; + } + if((now >= valeurDate && now <= valeurDate+3600000*2 && p.getEffectuee().equals("false"))) { + addElementList(p, listPrises); + cpt++; + } + + if(now > valeurDate+3600000*2) { + if(p.getEffectuee().equals("false")){ + supElementList(p,listPrises); + Intent i = new Intent(this,ServiceInitAlarme.class); + i.putExtra("heure",p.getHeure()); + startService(i); + } + else{ + p.setEffectuee("true"); + eventBDD.updatePrise(p.getId(),p); + } + } + } + } + if(cpt == 0){ + TextView textView = (TextView) findViewById(R.id.présence); + textView.setText(R.string.menu2); + } + else{ + TextView textView = (TextView) findViewById(R.id.présence); + textView.setText(""); + } + } + + public void onClickVomi(View view){ + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.menu3); + + DialogInterface.OnClickListener onClickYes = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + + Date date = new Date(); + SimpleDateFormat f1 = new SimpleDateFormat("dd/MM/yyyy"); + SimpleDateFormat f2 = new SimpleDateFormat("HH:mm"); + + String sEv = getString(R.string.menu9) + " " + f2.format(date); + Event ev = new Event(eventBDD.getIndiceMaxEvent()+1,f1.format(date),f2.format(date),sEv); + eventBDD.insertEvent(ev); + + long now = System.currentTimeMillis(); + + for(int i=0; i listP){ + listP.remove(p); + adapter.notifyDataSetChanged(); + } + + void supList(ArrayList listP){ + listP.clear(); + adapter.notifyDataSetChanged(); + } + + void addElementList(Prise2 p, ArrayList listP){ + listP.add(p); + adapter.notifyDataSetChanged(); + } + + public void displayConfirmation(View view) { + Context context = getApplicationContext(); + int duration = Toast.LENGTH_LONG; + Toast toast = Toast.makeText(context, R.string.menu6, duration); + toast.setGravity(Gravity.CENTER ,0,0); + toast.show(); + } + + public void onClickHistorique(View view){ + Intent i = new Intent(this, HistoriqueActivity.class); + startActivity(i); + } + + public void onClickGestionMedoc(View view){ + Intent i = new Intent(this, GestionActivity.class); + startActivity(i); + } + + public String chargementMedoc(String codeSource){ + String nomMedoc = null, nomMolecule = null; + String posologie = null, indications = null; + String nomImage = null; + int i2 = codeSource.indexOf(""); + codeSource = codeSource.substring(i2+4); + int i1 = codeSource.indexOf("

")+4; + i2 = codeSource.indexOf("("); + if(i1 != -1 && i2 != -1){ + nomMedoc = codeSource.substring(i1, i2); + i1 = codeSource.indexOf("(")+1; + i2 = codeSource.indexOf(")"); + nomMolecule = codeSource.substring(i1, i2); + } + + i1 = codeSource.indexOf("

"); + String image = codeSource.substring(i1,i2); + i1 = image.indexOf("src=./")+6; + i2 = image.indexOf("alt=")-1; + if(i1 != -1 && i2 != -1) nomImage = image.substring(i1,i2); + + i1 = codeSource.indexOf("

Posologie

") + 18; + i2 = codeSource.indexOf("

Indications

"); + if(i1 != -1 && i2 != -1) posologie = codeSource.substring(i1, i2); + i1 = codeSource.indexOf("

Indications

") + 20; + i2 = codeSource.indexOf(""); + if(i1 != -1 && i2 != -1) indications = codeSource.substring(i1, i2); + String s = nomMedoc + "XoXo" + nomMolecule + "XoXo" + nomImage + "XoXo" + posologie + "XoXo" + indications; + return s; + } + + public void onClickDownload(View view){ + final ImageButton imageButton = (ImageButton) findViewById(R.id.download); + imageButton.setColorFilter(R.color.colorPrimaryDark); + + fini = false; + + new AsyncTask(){ + @Override + protected String doInBackground(String... urlStr){ + String htmlCode = ""; + try{ + URL url = new URL(urlStr[0]); + BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); + + String inputLine; + while ((inputLine = in.readLine()) != null) { + htmlCode += inputLine; + } + in.close(); + + } catch (Exception e) {e.printStackTrace(); fini = true;} + return htmlCode.toString(); + } + + @Override + protected void onPostExecute(String codeSource){ + + ArrayList noms = new ArrayList(); + int i1 = codeSource.indexOf("
  • (){ + @Override + protected String doInBackground(String... urlStr){ + String htmlCode = ""; + try{ + URL url = new URL(urlStr[0]); + BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); + + String inputLine; + while ((inputLine = in.readLine()) != null) { + htmlCode += inputLine; + } + in.close(); + } catch (MalformedURLException e) { + e.printStackTrace(); + fini = true; + } catch (IOException e) { + filepath=null; + e.printStackTrace(); + fini = true; + } + return htmlCode.toString(); + } + + @Override + protected void onPostExecute(String codeSourcePage){ + res += chargementMedoc(codeSourcePage); + + String[] medocdoc = res.split("XoXo"); + String nom = medocdoc[0]; + String nomImage = medocdoc[2]; + + new AsyncTask(){ + @Override + protected String doInBackground(String... urlStr){ + String htmlCode = ""; + try{ + File SDCardRoot = Environment.getExternalStorageDirectory(); + String dossier = "medicaments"; + File file2 = new File(SDCardRoot,dossier); + file2.mkdir(); + if(file2.createNewFile()) + { + file2.createNewFile(); + } + + URL url = new URL(urlStr[0]); + HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + urlConnection.setRequestMethod("GET"); + urlConnection.setDoOutput(true); + urlConnection.connect(); + + String filename = urlStr[0].substring(25); + int i = filename.indexOf("."); + filename = filename.substring(0,i)+".png"; + + File file = new File(SDCardRoot+"/"+dossier,filename); + file.isFile(); + if(file.createNewFile()) + { + file.createNewFile(); + } + FileOutputStream fileOutput = new FileOutputStream(file); + InputStream inputStream = urlConnection.getInputStream(); + int totalSize = urlConnection.getContentLength(); + int downloadedSize = 0; + byte[] buffer = new byte[1024]; + int bufferLength; + while ( (bufferLength = inputStream.read(buffer)) > 0 ) { + fileOutput.write(buffer, 0, bufferLength); + downloadedSize += bufferLength; + } + fileOutput.close(); + if(downloadedSize==totalSize) filepath=file.getPath(); + + } catch (MalformedURLException e) { + e.printStackTrace(); + fini = true; + } catch (IOException e) { + filepath=null; + e.printStackTrace(); + fini = true; + } + return htmlCode.toString(); + } + + @Override + protected void onPostExecute(String codeSourcePage){ + } + + @Override + protected void onCancelled(){ + super.onCancelled(); + Toast.makeText(MainActivity.this,R.string.menu5,Toast.LENGTH_SHORT).show(); + fini = true; + } + }.execute("http://pharmacie.plil.fr/"+nomImage); + + boolean existe = false; + int indice = 0; + int w=1; + while(w <= eventBDD.getIndiceMaxMedoc() && !existe) { + Medicament m = eventBDD.getMedocWithId(w); + if (m.getNom1().equals(nom)){ + existe = true; + indice = m.getIdM(); + } + w++; + } + if(!existe) { + int i = medocdoc[2].indexOf("."); + medocdoc[2] = medocdoc[2].substring(0,i)+".png"; + medocdoc[2] = Environment.getExternalStorageDirectory().toString()+"/medicaments/"+medocdoc[2]; + Medicament m = new Medicament(eventBDD.getIndiceMaxMedoc()+1,medocdoc[0],medocdoc[1],medocdoc[3],medocdoc[4],medocdoc[2]); + eventBDD.insertMedoc(m); + } + else{ + int i = medocdoc[2].indexOf("."); + medocdoc[2] = medocdoc[2].substring(0,i)+".png"; + medocdoc[2] = Environment.getExternalStorageDirectory().toString()+"/medicaments/"+medocdoc[2]; + Medicament m = new Medicament(indice,medocdoc[0],medocdoc[1],medocdoc[3],medocdoc[4],medocdoc[2]); + eventBDD.updateMedoc(indice,m); + } + res = ""; + } + }.execute("http://pharmacie.plil.fr/"+s); + } + imageButton.clearColorFilter(); + if(fini) Toast.makeText(MainActivity.this,R.string.menu5,Toast.LENGTH_SHORT).show(); + else Toast.makeText(MainActivity.this,R.string.menu10,Toast.LENGTH_SHORT).show(); + } + + @Override + protected void onCancelled(){ + super.onCancelled(); + imageButton.clearColorFilter(); + Toast.makeText(MainActivity.this,R.string.menu5,Toast.LENGTH_SHORT).show(); + } + + }.execute("http://pharmacie.plil.fr/liste_fiche.php"); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + requestWindowFeature(Window.FEATURE_NO_TITLE); + + setContentView(R.layout.activity_main); + + eventBDD = new StringBDD(this); + eventBDD.open(); + } + + @Override + protected void onResume() { + eventBDD.open(); + super.onResume(); + + adapter = new PriseAdapterMenu(this,listPrises); + adapter.addListener(this); + list = (ListView)findViewById(R.id.list1); + list.setAdapter(adapter); + + gestionHeure(); + } + + @Override + protected void onPause() { + eventBDD.close(); + super.onPause(); + + adapter = new PriseAdapterMenu(this,listPrises); + adapter.addListener(this); + list = (ListView)findViewById(R.id.list1); + list.setAdapter(adapter); + + supList(listPrises); + } +} \ No newline at end of file diff --git a/partieAndroid/codesJava/Medicament.java b/partieAndroid/codesJava/Medicament.java new file mode 100644 index 0000000..ad482d8 --- /dev/null +++ b/partieAndroid/codesJava/Medicament.java @@ -0,0 +1,57 @@ +package com.example.martin.projetv5; + +/** + * Created by martin on 20/02/2017. + */ + +public class Medicament { + Integer idM; + String nom1; + String nom2; + String posologies; + String indications; + String logo; + + public Medicament(Integer mId, String mNom1, String mNom2, String poso, String indic, String mLogo){ + idM = mId; + nom1 = mNom1; + nom2 = mNom2; + posologies = poso; + indications = indic; + logo = mLogo; + } + + public void setIdM(Integer idM){ + this.idM = idM; + } + public void setNom1(String mNom1){ + nom1 = mNom1; + } + public void setNom2(String mNom2){ + nom2 = mNom2; + } + public void setPosologies(String poso) { + posologies = poso; + } + public void setIndications(String indic) { + indications = indic; + } + public void setLogo(String mLogo){ + logo = mLogo; + } + + public Integer getIdM(){ + return idM; + } + public String getNom1(){ + return nom1; + } + public String getNom2(){ + return nom2; + } + public String getPosologies(){ return posologies; } + public String getIndications(){ return indications; } + public String getLogo(){ + return logo; + } +} diff --git a/partieAndroid/codesJava/MedocAdapterMenu.java b/partieAndroid/codesJava/MedocAdapterMenu.java new file mode 100644 index 0000000..5fa1fd0 --- /dev/null +++ b/partieAndroid/codesJava/MedocAdapterMenu.java @@ -0,0 +1,96 @@ +package com.example.martin.projetv5; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by martin on 12/04/2017. + */ + +public class MedocAdapterMenu extends BaseAdapter { + public List mListM; + public Context mContext; + public LayoutInflater mInflater; + + public MedocAdapterMenu(Context context, List aListM){ + mContext = context; + mListM = aListM; + mInflater = LayoutInflater.from(mContext); + } + + public int getCount(){ + return mListM.size(); + } + + public Object getItem(int position){ + return mListM.get(position); + } + + public long getItemId(int position){ + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + RelativeLayout layoutItem; + + if (convertView == null) { + layoutItem = (RelativeLayout) mInflater.inflate(R.layout.medoc, parent, false); + } else { + layoutItem = (RelativeLayout) convertView; + } + + TextView nom1 = (TextView)layoutItem.findViewById(R.id.nom1); + TextView nom2 = (TextView)layoutItem.findViewById(R.id.nom2); + ImageView logo = (ImageView)layoutItem.findViewById(R.id.logo); + ImageButton modif = (ImageButton) layoutItem.findViewById(R.id.boutonModif); + + nom1.setText(mListM.get(position).getNom1()); + nom2.setText(mListM.get(position).getNom2()); + + File imgFile = new File(mListM.get(position).getLogo()); + if(imgFile.exists()){ + Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); + logo.setImageBitmap(myBitmap); + } + + modif.setTag(position); + modif.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View v){ + Integer position = (Integer)v.getTag(); + sendListener(mListM.get(position),position); + } + }); + + return layoutItem; + } + + public interface MedocAdapterListener{ + void onClickButton(Medicament item, int position); + } + + private ArrayList mListListener = new ArrayList(); + + public void addListener(MedocAdapterMenu.MedocAdapterListener aListener){ + mListListener.add(aListener); + } + + private void sendListener(Medicament item, int position){ + for(int i = mListListener.size()-1; i>=0; i--){ + mListListener.get(i).onClickButton(item, position); + } + } +} diff --git a/partieAndroid/codesJava/ModifMedocActivity.java b/partieAndroid/codesJava/ModifMedocActivity.java new file mode 100644 index 0000000..597ca6d --- /dev/null +++ b/partieAndroid/codesJava/ModifMedocActivity.java @@ -0,0 +1,208 @@ +package com.example.martin.projetv5; + +import android.content.DialogInterface; +import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.Bundle; +import android.support.v7.app.AlertDialog; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +import java.util.ArrayList; +import java.util.Collections; + +/** + * Created by martin on 12/04/2017. + */ + +public class ModifMedocActivity extends AppCompatActivity implements PriseAdapterMedoc.PriseAdapterListener { + + ArrayList listPrises = new ArrayList<>(); + PriseAdapterMedoc adapter = null; + ListView list = null; + StringBDD eventBDD = null; + Medicament medicament = null; + + void supElementList(Prise2 p, ArrayList listP){ + listP.remove(p); + adapter.notifyDataSetChanged(); + } + + void supList(ArrayList listP){ + listP.clear(); + adapter.notifyDataSetChanged(); + } + + void addElementList(Prise2 p, ArrayList listP){ + listP.add(p); + } + + public void onClickDelete(final Prise2 item, int position){ + AlertDialog.Builder builder = new AlertDialog.Builder(this); + + DialogInterface.OnClickListener onClickYes = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + supElementList(item, listPrises); + eventBDD.removePriseWithID(item.getId()); + + } + }; + + builder.setMessage(R.string.modif8); + builder.setPositiveButton(R.string.oui,onClickYes); + builder.setNegativeButton(R.string.non,null); + builder.show(); + } + + void gestionPrises(){ + for(int w=0; w 2 || decoupe[0].equals("")) + Toast.makeText(view.getContext(), R.string.modif9, Toast.LENGTH_SHORT).show(); + else { + h = Integer.parseInt(decoupe[0]); + if (size == 1) m = 0; + else m = Integer.parseInt(decoupe[1]); + + String s; + if (h >= 24 || h < 0) + Toast.makeText(view.getContext(), R.string.modif9, Toast.LENGTH_SHORT).show(); + else { + if (m >= 60 || m < 0) + Toast.makeText(view.getContext(), R.string.modif9, Toast.LENGTH_SHORT).show(); + else { + if (m == 0) s = h.toString() + "h" + "0" + m.toString(); + else s = h.toString() + "h" + m.toString(); + + int w=1; + boolean out = false; + while(w <= eventBDD.getIndiceMaxPrise() && !out){ + Prise2 p = eventBDD.getPriseWithId(w); + if(p == null) out = true; + else w++; + } + + Prise2 p = new Prise2(w, medicament.getIdM(), "false", s); + eventBDD.insertPrise(p); + + Intent i = new Intent(ModifMedocActivity.this, ServiceInitAlarme.class); + i.putExtra("heure", p.getHeure()); + startService(i); + + supList(listPrises); + gestionPrises(); + } + } + } + }catch (Exception e){ + Toast.makeText(ModifMedocActivity.this,R.string.modif9,Toast.LENGTH_SHORT).show(); + } + } + }; + + builder.setPositiveButton(R.string.enregistrer,onClickYes); + builder.setNegativeButton(R.string.annuler,null); + builder.show(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.modif_layout); + + eventBDD = new StringBDD(this); + eventBDD.open(); + + Intent intent = getIntent(); + Integer idMedoc = intent.getIntExtra("id",0); + medicament = eventBDD.getMedocWithId(idMedoc); + + ImageView logo = (ImageView) findViewById(R.id.logo); + Bitmap bitmap = BitmapFactory.decodeFile(medicament.getLogo()); + logo.setImageBitmap(bitmap); + TextView nom1 = (TextView) findViewById(R.id.nom1); + nom1.setText(medicament.getNom1()); + TextView nom2 = (TextView) findViewById(R.id.nom2); + nom2.setText(medicament.getNom2()); + } + + @Override + protected void onResume() { + eventBDD.open(); + super.onResume(); + + adapter = new PriseAdapterMedoc(this,listPrises); + adapter.addListener(this); + list = (ListView)findViewById(R.id.listePrises); + list.setAdapter(adapter); + + gestionPrises(); + } + + @Override + protected void onPause() { + super.onPause(); + + adapter = new PriseAdapterMedoc(this,listPrises); + adapter.addListener(this); + list = (ListView)findViewById(R.id.listePrises); + list.setAdapter(adapter); + + eventBDD.close(); + supList(listPrises); + } +} \ No newline at end of file diff --git a/partieAndroid/codesJava/Prise2.java b/partieAndroid/codesJava/Prise2.java new file mode 100644 index 0000000..6826b5a --- /dev/null +++ b/partieAndroid/codesJava/Prise2.java @@ -0,0 +1,74 @@ +package com.example.martin.projetv5; + +/** + * Created by martin on 20/02/2017. + */ + +public class Prise2 implements Comparable{ + Integer idP; + Integer idMedoc; + String effectuee; + String heurePrescrite; + + public Prise2(Integer pId, Integer pIdMedoc, String pEffectuee, String pHeure) { + idP = pId; + idMedoc = pIdMedoc; + effectuee = pEffectuee; + heurePrescrite = pHeure; + } + + @Override + public int compareTo(Prise2 p) { + String[] s1 = this.getHeure().split("h"); + String[] s2 = p.getHeure().split("h"); + + int cmp; + if (Integer.parseInt(s1[0]) > Integer.parseInt(s2[0])) + cmp = +1; + else if (Integer.parseInt(s1[0]) < Integer.parseInt(s2[0])) + cmp = -1; + else{ + if (Integer.parseInt(s1[1]) > Integer.parseInt(s2[1])) + cmp = +1; + else if (Integer.parseInt(s1[1]) < Integer.parseInt(s2[1])) + cmp = -1; + else + cmp = 0; + } + + return cmp; + + /* + if(s1[0].compareTo(s2[0]) == 0){; + return s1[1].compareTo(s2[1]); + } + else return s1[0].compareTo(s2[0]); + */ + } + + public void setId(Integer pId){ + idP = pId; + } + public void setIdMedoc(Integer pIdM){ + idMedoc = pIdM; + } + public void setEffectuee(String pEffectuee){ + effectuee = pEffectuee; + } + public void setHeure(String pHeure){ + heurePrescrite = pHeure; + } + + public Integer getId(){ + return idP; + } + public Integer getIdMedoc(){ + return idMedoc; + } + public String getEffectuee(){ + return effectuee; + } + public String getHeure(){ + return heurePrescrite; + } +} diff --git a/partieAndroid/codesJava/PriseAdapterMedoc.java b/partieAndroid/codesJava/PriseAdapterMedoc.java new file mode 100644 index 0000000..90f38cf --- /dev/null +++ b/partieAndroid/codesJava/PriseAdapterMedoc.java @@ -0,0 +1,84 @@ +package com.example.martin.projetv5; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageButton; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by martin on 20/02/2017. + */ + +public class PriseAdapterMedoc extends BaseAdapter { + public List mListP; + public Context mContext; + public LayoutInflater mInflater; + + public PriseAdapterMedoc(Context context, List aListP){ + mContext = context; + mListP = aListP; + mInflater = LayoutInflater.from(mContext); + } + + public int getCount(){ + return mListP.size(); + } + + public Object getItem(int position){ + return mListP.get(position); + } + + public long getItemId(int position){ + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + RelativeLayout layoutItem; + + if (convertView == null) { + layoutItem = (RelativeLayout) mInflater.inflate(R.layout.prise_medoc, parent, false); + } else { + layoutItem = (RelativeLayout) convertView; + } + + TextView horloge = (TextView) layoutItem.findViewById(R.id.horloge); + ImageButton change = (ImageButton) layoutItem.findViewById(R.id.boutonConfirm); + + horloge.setText(mListP.get(position).getHeure()); + change.setImageResource(R.drawable.delete); + + change.setTag(position); + change.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View v){ + Integer position = (Integer)v.getTag(); + sendListener(mListP.get(position),position); + } + }); + + return layoutItem; + } + + public interface PriseAdapterListener{ + void onClickDelete(Prise2 item, int position); + } + + private ArrayList mListListener = new ArrayList(); + + public void addListener(PriseAdapterListener aListener){ + mListListener.add(aListener); + } + + private void sendListener(Prise2 item, int position){ + for(int i = mListListener.size()-1; i>=0; i--){ + mListListener.get(i).onClickDelete(item, position); + } + } +} diff --git a/partieAndroid/codesJava/PriseAdapterMenu.java b/partieAndroid/codesJava/PriseAdapterMenu.java new file mode 100644 index 0000000..b2a2d06 --- /dev/null +++ b/partieAndroid/codesJava/PriseAdapterMenu.java @@ -0,0 +1,102 @@ +package com.example.martin.projetv5; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by martin on 27/04/2017. + */ + +public class PriseAdapterMenu extends BaseAdapter { + public List mListP; + public Context mContext; + public LayoutInflater mInflater; + public StringBDD eventBDD; + + public PriseAdapterMenu(Context context, List aListP){ + mContext = context; + mListP = aListP; + mInflater = LayoutInflater.from(mContext); + } + + public int getCount(){ + return mListP.size(); + } + + public Object getItem(int position){ + return mListP.get(position); + } + + public long getItemId(int position){ + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + RelativeLayout layoutItem; + + if (convertView == null) { + layoutItem = (RelativeLayout) mInflater.inflate(R.layout.prise_menu, parent, false); + } else { + layoutItem = (RelativeLayout) convertView; + } + + ImageView logoMedoc = (ImageView) layoutItem.findViewById(R.id.logoMenu); + TextView horloge = (TextView) layoutItem.findViewById(R.id.horlogeMenu); + TextView nom = (TextView) layoutItem.findViewById(R.id.nomMenu); + ImageButton change = (ImageButton) layoutItem.findViewById(R.id.boutonConfirmMenu); + + eventBDD = new StringBDD(null); + eventBDD.open(); + Medicament m = eventBDD.getMedocWithId(mListP.get(position).getIdMedoc()); + nom.setText(m.getNom1()); + File imgFile = new File(m.getLogo()); + if(imgFile.exists()){ + Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); + logoMedoc.setImageBitmap(myBitmap); + } + + + horloge.setText(mListP.get(position).getHeure()); + change.setImageResource(R.drawable.edit); + + change.setTag(position); + change.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View v){ + Integer position = (Integer)v.getTag(); + sendListener(mListP.get(position),position); + } + }); + + return layoutItem; + } + + public interface PriseAdapterListener{ + void onClickButton(Prise2 item, int position); + } + + private ArrayList mListListener = new ArrayList(); + + public void addListener(PriseAdapterListener aListener){ + mListListener.add(aListener); + } + + private void sendListener(Prise2 item, int position){ + for(int i = mListListener.size()-1; i>=0; i--){ + mListListener.get(i).onClickButton(item, position); + } + } +} diff --git a/partieAndroid/codesJava/ServiceInitAlarme.java b/partieAndroid/codesJava/ServiceInitAlarme.java new file mode 100644 index 0000000..4c0939a --- /dev/null +++ b/partieAndroid/codesJava/ServiceInitAlarme.java @@ -0,0 +1,36 @@ +package com.example.martin.projetv5; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; + +/** + * Created by martin on 06/05/2017. + */ + +public class ServiceInitAlarme extends Service { + Alarm alarm = new Alarm(); + public void onCreate() + { + super.onCreate(); + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) + { + String s = intent.getStringExtra("heure"); + alarm.setAlarm(this,s); + return START_STICKY; + } + + @Override + public IBinder onBind(Intent intent) + { + return null; + } + + @Override + public void onDestroy(){ + super.onDestroy(); + } +} diff --git a/partieAndroid/codesJava/StringBDD.java b/partieAndroid/codesJava/StringBDD.java new file mode 100644 index 0000000..3f94096 --- /dev/null +++ b/partieAndroid/codesJava/StringBDD.java @@ -0,0 +1,247 @@ +package com.example.martin.projetv5; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; + +/** + * Created by martin on 21/02/2017. + */ + +public class StringBDD { + private static final String TABLE_EVENTS = "table_events"; + private static final String COL_ID_EV = "ID_ev"; + private static final int NUM_COL_ID_EV = 0; + private static final String COL_DATE = "Date"; + private static final int NUM_COL_DATE = 1; + private static final String COL_HEURE_EV = "Heure_ev"; + private static final int NUM_COL_HEURE_EV = 2; + private static final String COL_EVENT = "Event"; + private static final int NUM_COL_EVENT = 3; + + private static final String TABLE_PRISES = "table_prises"; + private static final String COL_ID_P = "ID_prise"; + private static final int NUM_COL_ID_P = 0; + private static final String COL_MEDOC = "Medoc"; + private static final int NUM_COL_MEDOC = 1; + private static final String COL_HEURE = "Heure"; + private static final int NUM_COL_HEURE = 2; + private static final String COL_BOOL = "Bool"; + private static final int NUM_COL_BOOL = 3; + + private static final String TABLE_MEDOCS = "table_medocs"; + private static final String COL_ID_M = "ID_medoc"; + private static final int NUM_COL_ID_M = 0; + private static final String COL_NOM1 = "Nom1"; + private static final int NUM_COL_NOM1 = 1; + private static final String COL_NOM2 = "Nom2"; + private static final int NUM_COL_NOM2 = 2; + private static final String COL_POSO = "Posologies"; + private static final int NUM_COL_POSO = 3; + private static final String COL_INFOS = "Indications"; + private static final int NUM_COL_INFOS = 4; + private static final String COL_LOGO = "Logo"; + private static final int NUM_COL_LOGO = 5; + + private SQLiteDatabase bdd; + + private StringSQLite maBaseSQLite; + + private static final int VERSION_BDD = 1; + + public StringBDD(Context context) { + maBaseSQLite = StringSQLite.getInstance(context); + } + + public void open() { + bdd = maBaseSQLite.getWritableDatabase(); + } + + public void close() { + bdd.close(); + } + + public SQLiteDatabase getBDD() { + return bdd; + } + + //------- Gestion BDD event ----------- + + public long insertEvent(Event ev) { + //Création d'un ContentValues (fonctionne comme une HashMap) + ContentValues values = new ContentValues(); + //on lui ajoute une valeur associée à une clé (qui est le nom de la colonne dans laquelle on veut mettre la valeur) + values.put(COL_ID_EV, ev.getId()); + values.put(COL_DATE, ev.getDate()); + values.put(COL_HEURE_EV, ev.getHeure()); + values.put(COL_EVENT, ev.getEvenement()); + //on insère l'objet dans la BDD via le ContentValues + return bdd.insert(TABLE_EVENTS, null, values); + } + + public int getIndiceMaxEvent(){ + Cursor c = bdd.rawQuery("select "+COL_ID_EV+" from "+TABLE_EVENTS,null); + return c.getCount(); + } + + public Event getEventWithId(Integer id){ + //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) + 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); + return cursorToEvent(c); + } + + //Cette méthode permet de convertir un cursor en une prise + private Event cursorToEvent(Cursor c){ + //si aucun élément n'a été retourné dans la requête, on renvoie null + if (c.getCount() == 0) + return null; + + //Sinon on se place sur le premier élément + c.moveToFirst(); + //On créé une prise + Event ev = new Event(null,null,null,null); + //on lui affecte toutes les infos grâce aux infos contenues dans le Cursor + ev.setId(c.getInt(NUM_COL_ID_EV)); + ev.setDate(c.getString(NUM_COL_DATE)); + ev.setHeure(c.getString(NUM_COL_HEURE_EV)); + ev.setEvenement(c.getString(NUM_COL_EVENT)); + //On ferme le cursor + c.close(); + + //On retourne la prise + return ev; + } + + //------- Gestion BDD prises ----------- + + public long insertPrise(Prise2 prise){ + //Création d'un ContentValues (fonctionne comme une HashMap) + ContentValues values = new ContentValues(); + //on lui ajoute une valeur associée à une clé (qui est le nom de la colonne dans laquelle on veut mettre la valeur) + values.put(COL_ID_P,prise.getId()); + values.put(COL_MEDOC, prise.getIdMedoc()); + values.put(COL_HEURE, prise.getHeure()); + values.put(COL_BOOL, prise.getEffectuee()); + //on insère l'objet dans la BDD via le ContentValues + return bdd.insert(TABLE_PRISES, null, values); + } + + public int updatePrise(int id, Prise2 prise){ + //La mise à jour d'une prise dans la BDD fonctionne plus ou moins comme une insertion + //il faut simplement préciser quelle prise on doit mettre à jour grâce à l'ID + ContentValues values = new ContentValues(); + values.put(COL_ID_P, prise.getId()); + values.put(COL_MEDOC, prise.getIdMedoc()); + values.put(COL_HEURE, prise.getHeure()); + values.put(COL_BOOL, prise.getEffectuee()); + return bdd.update(TABLE_PRISES, values, COL_ID_P + " = " +id, null); + } + + public int removePriseWithID(int id){ + //Suppression d'une prise de la BDD grâce à l'ID + return bdd.delete(TABLE_PRISES, COL_ID_P + " = " +id, null); + } + + public Prise2 getPriseWithId(Integer id){ + //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) + 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); + return cursorToPrise(c); + } + + public int getIndiceMaxPrise(){ + Cursor c = bdd.rawQuery("select "+COL_ID_P+" from "+TABLE_PRISES,null); + return c.getCount(); + } + + //Cette méthode permet de convertir un cursor en une prise + private Prise2 cursorToPrise(Cursor c){ + //si aucun élément n'a été retourné dans la requête, on renvoie null + if (c.getCount() == 0) + return null; + + //Sinon on se place sur le premier élément + c.moveToFirst(); + //On créé une prise + Prise2 prise = new Prise2(null,null,null,null); + //on lui affecte toutes les infos grâce aux infos contenues dans le Cursor + prise.setId(c.getInt(NUM_COL_ID_P)); + prise.setIdMedoc(c.getInt(NUM_COL_MEDOC)); + prise.setHeure(c.getString(NUM_COL_HEURE)); + prise.setEffectuee(c.getString(NUM_COL_BOOL)); + //On ferme le cursor + c.close(); + + //On retourne la prise + return prise; + } + + //------- Gestion BDD medocs ----------- + + public long insertMedoc(Medicament medicament){ + //Création d'un ContentValues (fonctionne comme une HashMap) + ContentValues values = new ContentValues(); + //on lui ajoute une valeur associée à une clé (qui est le nom de la colonne dans laquelle on veut mettre la valeur) + values.put(COL_ID_M, medicament.getIdM()); + values.put(COL_NOM1, medicament.getNom1()); + values.put(COL_NOM2, medicament.getNom2()); + values.put(COL_POSO, medicament.getPosologies()); + values.put(COL_INFOS, medicament.getIndications()); + values.put(COL_LOGO, medicament.getLogo()); + //on insère l'objet dans la BDD via le ContentValues + return bdd.insert(TABLE_MEDOCS, null, values); + } + + public int updateMedoc(int id, Medicament medicament){ + //La mise à jour d'une prise dans la BDD fonctionne plus ou moins comme une insertion + //il faut simplement préciser quelle prise on doit mettre à jour grâce à l'ID + ContentValues values = new ContentValues(); + values.put(COL_ID_M, medicament.getIdM()); + values.put(COL_NOM1, medicament.getNom1()); + values.put(COL_NOM2, medicament.getNom2()); + values.put(COL_POSO, medicament.getPosologies()); + values.put(COL_INFOS, medicament.getIndications()); + values.put(COL_LOGO, medicament.getLogo()); + return bdd.update(TABLE_MEDOCS, values, COL_ID_M + " = " +id, null); + } + + public Medicament getMedocWithId(Integer id){ + //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) + 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); + return cursorToMedoc(c); + } + + public Medicament getMedocWithNom1(String nom){ + //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) + 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); + return cursorToMedoc(c); + } + + public int getIndiceMaxMedoc(){ + Cursor c = bdd.rawQuery("select "+COL_ID_M+" from "+TABLE_MEDOCS,null); + return c.getCount(); + } + + private Medicament cursorToMedoc(Cursor c){ + //si aucun élément n'a été retourné dans la requête, on renvoie null + if (c.getCount() == 0) + return null; + + //Sinon on se place sur le premier élément + c.moveToFirst(); + //On créé une prise + Medicament medicament = new Medicament(null,null,null,null,null,null); + //on lui affecte toutes les infos grâce aux infos contenues dans le Cursor + medicament.setIdM(c.getInt(NUM_COL_ID_M)); + medicament.setNom1(c.getString(NUM_COL_NOM1)); + medicament.setNom2(c.getString(NUM_COL_NOM2)); + medicament.setPosologies(c.getString(NUM_COL_POSO)); + medicament.setIndications(c.getString(NUM_COL_INFOS)); + medicament.setLogo(c.getString(NUM_COL_LOGO)); + //On ferme le cursor + c.close(); + + //On retourne la prise + return medicament; + } +} diff --git a/partieAndroid/codesJava/StringSQLite.java b/partieAndroid/codesJava/StringSQLite.java new file mode 100644 index 0000000..1dba4a2 --- /dev/null +++ b/partieAndroid/codesJava/StringSQLite.java @@ -0,0 +1,75 @@ +package com.example.martin.projetv5; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +/** + * Created by martin on 21/02/2017. + */ + +public class StringSQLite extends SQLiteOpenHelper { + private static final int VERSION_BDD = 1; + private static final String NOM_BDD = "evenements.db"; + private static StringSQLite sInstance; + + private static final String TABLE_EVENTS = "table_events"; + private static final String TABLE_PRISES = "table_prises"; + private static final String TABLE_MEDOCS = "table_medocs"; + + private static final String COL_ID_EV = "ID_ev"; + private static final String COL_DATE = "Date"; + private static final String COL_HEURE_EV = "Heure_ev"; + private static final String COL_EVENT = "Event"; + + private static final String COL_ID_P = "ID_prise"; + private static final String COL_MEDOC = "Medoc"; + private static final String COL_HEURE = "Heure"; + private static final String COL_BOOL = "Bool"; + + private static final String COL_ID_M = "ID_medoc"; + private static final String COL_NOM1 = "Nom1"; + private static final String COL_NOM2 = "Nom2"; + private static final String COL_POSO = "Posologies"; + private static final String COL_INFOS = "Indications"; + private static final String COL_LOGO = "Logo"; + + private static final String CREATE_BDD = "CREATE TABLE " + TABLE_EVENTS + " (" + + COL_ID_EV + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_DATE + " TEXT NOT NULL, " + + COL_HEURE_EV + " TEXT NOT NULL, " + COL_EVENT + " TEXT NOT NULL);"; + + private static final String CREATE_BDD_PRISES = "CREATE TABLE " + TABLE_PRISES + " (" + + COL_ID_P + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_MEDOC + " TEXT NOT NULL, " + + COL_HEURE + " TEXT NOT NULL, " + COL_BOOL + " TEXT NOT NULL);"; + + private static final String CREATE_BDD_MEDOCS = "CREATE TABLE " + TABLE_MEDOCS + " (" + + COL_ID_M + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_NOM1 + " TEXT NOT NULL, " + + COL_NOM2 + " TEXT NOT NULL, " + COL_POSO + " TEXT NOT NULL, " + COL_INFOS + " TEXT NOT NULL, " + + COL_LOGO + " TEXT NOT NULL);"; + + public static synchronized StringSQLite getInstance(Context context){ + if(sInstance == null){sInstance = new StringSQLite(context);} + return sInstance; + } + + public StringSQLite(Context context){ + super(context, NOM_BDD, null, VERSION_BDD); + } + + @Override + public void onCreate(SQLiteDatabase db) { + //on crée la table à partir de la requête écrite dans la variable CREATE_BDD + db.execSQL(CREATE_BDD); + db.execSQL(CREATE_BDD_PRISES); + db.execSQL(CREATE_BDD_MEDOCS); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + //On supprime la table puis la recrée afin de faire repartir les id à 0 + db.execSQL("DROP TABLE " + TABLE_EVENTS + ";"); + db.execSQL("DROP TABLE " + TABLE_PRISES + ";"); + db.execSQL("DROP TABLE " + TABLE_MEDOCS + ";"); + onCreate(db); + } +} \ No newline at end of file diff --git a/partieAndroid/res/drawable/checked.png b/partieAndroid/res/drawable/checked.png new file mode 100644 index 0000000..1b1b03b Binary files /dev/null and b/partieAndroid/res/drawable/checked.png differ diff --git a/partieAndroid/res/drawable/delete.png b/partieAndroid/res/drawable/delete.png new file mode 100644 index 0000000..67ca616 Binary files /dev/null and b/partieAndroid/res/drawable/delete.png differ diff --git a/partieAndroid/res/drawable/dl.png b/partieAndroid/res/drawable/dl.png new file mode 100644 index 0000000..02222c8 Binary files /dev/null and b/partieAndroid/res/drawable/dl.png differ diff --git a/partieAndroid/res/drawable/edit.png b/partieAndroid/res/drawable/edit.png new file mode 100644 index 0000000..74fde8e Binary files /dev/null and b/partieAndroid/res/drawable/edit.png differ diff --git a/partieAndroid/res/drawable/gelules.png b/partieAndroid/res/drawable/gelules.png new file mode 100644 index 0000000..3735492 Binary files /dev/null and b/partieAndroid/res/drawable/gelules.png differ diff --git a/partieAndroid/res/drawable/info.png b/partieAndroid/res/drawable/info.png new file mode 100644 index 0000000..b758078 Binary files /dev/null and b/partieAndroid/res/drawable/info.png differ diff --git a/partieAndroid/res/drawable/next.png b/partieAndroid/res/drawable/next.png new file mode 100644 index 0000000..8004336 Binary files /dev/null and b/partieAndroid/res/drawable/next.png differ diff --git a/partieAndroid/res/drawable/pill.png b/partieAndroid/res/drawable/pill.png new file mode 100644 index 0000000..67b06f7 Binary files /dev/null and b/partieAndroid/res/drawable/pill.png differ diff --git a/partieAndroid/res/drawable/pills.png b/partieAndroid/res/drawable/pills.png new file mode 100644 index 0000000..8fba087 Binary files /dev/null and b/partieAndroid/res/drawable/pills.png differ diff --git a/partieAndroid/res/drawable/plus.png b/partieAndroid/res/drawable/plus.png new file mode 100644 index 0000000..cc85423 Binary files /dev/null and b/partieAndroid/res/drawable/plus.png differ diff --git a/partieAndroid/res/drawable/schedule.png b/partieAndroid/res/drawable/schedule.png new file mode 100644 index 0000000..49d9538 Binary files /dev/null and b/partieAndroid/res/drawable/schedule.png differ diff --git a/partieAndroid/res/drawable/vomi.png b/partieAndroid/res/drawable/vomi.png new file mode 100644 index 0000000..cf13328 Binary files /dev/null and b/partieAndroid/res/drawable/vomi.png differ diff --git a/partieAndroid/res/layout/activity_main.xml b/partieAndroid/res/layout/activity_main.xml new file mode 100644 index 0000000..50de758 --- /dev/null +++ b/partieAndroid/res/layout/activity_main.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/res/layout/ajout_layout.xml b/partieAndroid/res/layout/ajout_layout.xml new file mode 100644 index 0000000..c7ea58c --- /dev/null +++ b/partieAndroid/res/layout/ajout_layout.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/res/layout/dialogue_prise.xml b/partieAndroid/res/layout/dialogue_prise.xml new file mode 100644 index 0000000..f1c4afe --- /dev/null +++ b/partieAndroid/res/layout/dialogue_prise.xml @@ -0,0 +1,31 @@ + + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/res/layout/event.xml b/partieAndroid/res/layout/event.xml new file mode 100644 index 0000000..804c9e1 --- /dev/null +++ b/partieAndroid/res/layout/event.xml @@ -0,0 +1,21 @@ + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/res/layout/gestion_layout.xml b/partieAndroid/res/layout/gestion_layout.xml new file mode 100644 index 0000000..21a78b1 --- /dev/null +++ b/partieAndroid/res/layout/gestion_layout.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/res/layout/historique_layout.xml b/partieAndroid/res/layout/historique_layout.xml new file mode 100644 index 0000000..872c349 --- /dev/null +++ b/partieAndroid/res/layout/historique_layout.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/res/layout/medoc.xml b/partieAndroid/res/layout/medoc.xml new file mode 100644 index 0000000..f939a6f --- /dev/null +++ b/partieAndroid/res/layout/medoc.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/res/layout/modif_layout.xml b/partieAndroid/res/layout/modif_layout.xml new file mode 100644 index 0000000..20bb511 --- /dev/null +++ b/partieAndroid/res/layout/modif_layout.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/res/layout/prise_medoc.xml b/partieAndroid/res/layout/prise_medoc.xml new file mode 100644 index 0000000..84b2015 --- /dev/null +++ b/partieAndroid/res/layout/prise_medoc.xml @@ -0,0 +1,30 @@ + + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/res/layout/prise_menu.xml b/partieAndroid/res/layout/prise_menu.xml new file mode 100644 index 0000000..79aa9af --- /dev/null +++ b/partieAndroid/res/layout/prise_menu.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/partieAndroid/res/mipmap-hdpi/ic_launcher.png b/partieAndroid/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/partieAndroid/res/mipmap-hdpi/ic_launcher.png differ diff --git a/partieAndroid/res/mipmap-mdpi/ic_launcher.png b/partieAndroid/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/partieAndroid/res/mipmap-mdpi/ic_launcher.png differ diff --git a/partieAndroid/res/mipmap-xhdpi/ic_launcher.png b/partieAndroid/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/partieAndroid/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/partieAndroid/res/mipmap-xxhdpi/ic_launcher.png b/partieAndroid/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/partieAndroid/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/partieAndroid/res/mipmap-xxxhdpi/ic_launcher.png b/partieAndroid/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..aee44e1 Binary files /dev/null and b/partieAndroid/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/partieAndroid/res/values-fr/strings.xml b/partieAndroid/res/values-fr/strings.xml new file mode 100644 index 0000000..9b6ac69 --- /dev/null +++ b/partieAndroid/res/values-fr/strings.xml @@ -0,0 +1,42 @@ + + + Tech\' Your Pill + + OUI + NON + OK + ANNULER + ENREGISTRER + + Vos prises du moment : + Vous n\'avez aucun médicament à prendre pour le moment. + CONFIRMATION + Confirmation de la prise de + Une erreur est survenue. Vérifiez votre accès à internet. + La prise a été enregistrée. + pris à + Avez-vous été pris de vomissements ? + Vomissements subis vers + Fin du téléchargement. + + Historique de vos prises : + + Liste de vos médicaments : + Vous ne prenez actuellement aucun médicament. + + Nom du médicament + Nom incorrect. + Vous prenez déjà ce médicament. + + Quand prendre ce médicament ? + Nom du médicament : + Nom de la molécule : + Posologie : + Indications : + Heure de la prise : + (dans la même forme que l\'exemple) + Supprimer la prise ? + Heure incorrecte. + + Il est l\'heure de prendre vos cachets ! + \ No newline at end of file diff --git a/partieAndroid/res/values-w820dp/dimens.xml b/partieAndroid/res/values-w820dp/dimens.xml new file mode 100644 index 0000000..62df187 --- /dev/null +++ b/partieAndroid/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/partieAndroid/res/values/colors.xml b/partieAndroid/res/values/colors.xml new file mode 100644 index 0000000..1621932 --- /dev/null +++ b/partieAndroid/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #f1fdff + #90daf1 + #1a2163 + diff --git a/partieAndroid/res/values/dimens.xml b/partieAndroid/res/values/dimens.xml new file mode 100644 index 0000000..295b5a9 --- /dev/null +++ b/partieAndroid/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/partieAndroid/res/values/strings.xml b/partieAndroid/res/values/strings.xml new file mode 100644 index 0000000..ae76b2d --- /dev/null +++ b/partieAndroid/res/values/strings.xml @@ -0,0 +1,41 @@ + + Tech\' Your Pill + + YES + NO + OK + CANCEL + RECORD + + What you should take now: + Nothing to be taken now. + Do you confirm... + Are you just taking + An error has occurred. Check your internet access. + Your medication has been recorded. + taken at + Have you been vomiting ? + Vomiting at around + Download completed. + + Your medication history: + + Your medicine list: + You are not taking any medicine. + + Medicine name + Invalid name. + You are already taking this medicine. + + When should I take it ? + Medicine name: + Molecule name: + Dosage: + Further information + Add a new schedule: + (as shown in the example) + Delete this scheduled hour? + Invalid hour. + + It is time to take your medication ! + diff --git a/partieAndroid/res/values/styles.xml b/partieAndroid/res/values/styles.xml new file mode 100644 index 0000000..8cf65c6 --- /dev/null +++ b/partieAndroid/res/values/styles.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/partieAndroid/res/values/values.xml b/partieAndroid/res/values/values.xml new file mode 100644 index 0000000..82fb55c --- /dev/null +++ b/partieAndroid/res/values/values.xml @@ -0,0 +1,6 @@ + + + @color/colorPrimary + @color/colorPrimaryDark + @color/colorAccent + \ No newline at end of file diff --git a/partieWeb/add_medoc.php b/partieWeb/add_medoc.php new file mode 100644 index 0000000..8bdd580 --- /dev/null +++ b/partieWeb/add_medoc.php @@ -0,0 +1,24 @@ + + + + +
    +
    +

    Nom du médicament :

    + +

    Nom molécule :

    + +

    Photo du medicament :

    + +
    +

    Posologie :

    + +
    +

    Indications :

    +
    + + + +
    + + \ No newline at end of file diff --git a/partieWeb/aspirine.html b/partieWeb/aspirine.html new file mode 100644 index 0000000..c18e6f2 --- /dev/null +++ b/partieWeb/aspirine.html @@ -0,0 +1,10 @@ +
    +
    +
    +

    +
    +

    aspirine(acide acetylsalicylique)

    +

    aspirine


    Posologie

    3 a 4 fois par jour

    Indications

    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 + +
    \ No newline at end of file diff --git a/partieWeb/aspirine.jpg b/partieWeb/aspirine.jpg new file mode 100644 index 0000000..c30d0fd Binary files /dev/null and b/partieWeb/aspirine.jpg differ diff --git a/partieWeb/liste_fiche.php b/partieWeb/liste_fiche.php new file mode 100644 index 0000000..e2ae827 --- /dev/null +++ b/partieWeb/liste_fiche.php @@ -0,0 +1,25 @@ + + + +
    +'; +if($dossier = opendir('.')) +{ +while(false !==($fichier = readdir($dossier))) +{ + if($fichier != '.' && $fichier != '..' && preg_match('/html/i',$fichier)) + { + echo '
  • ' . $fichier . '
  • '; + } +} +closedir($dossier); +} +else + echo 'le dossier n\' a pas pu être ouvert'; +$bug='.html'; + if(file_exists($bug)) + unlink( $bug ) ; +?> + + \ No newline at end of file diff --git a/partieWeb/menu.php b/partieWeb/menu.php new file mode 100644 index 0000000..99fad11 --- /dev/null +++ b/partieWeb/menu.php @@ -0,0 +1,20 @@ + + + +
    +

    Menu

    +
    +

    +

    +
    + + + + + + diff --git a/partieWeb/page.css b/partieWeb/page.css new file mode 100644 index 0000000..0fb77ca --- /dev/null +++ b/partieWeb/page.css @@ -0,0 +1,94 @@ +#container + { + margin: 1em auto; + width: 650px; + text-align:left; + background-color:#F7F2E0; + border: 1px solid #676767; + } +#container1 + { + margin: 1em auto; + width: 650px; + text-align:center; + background-color:#F7F2E0; + border: 1px solid #676767; + } +#header + { + height: 53px; + background-image: url(header.jpg); + background-repeat: no-repeat; + background-position: 0 0; + border-bottom: 1px solid #fff; + position: relative; + } + #header2 + { + height: 53px; + text-align:center; + background-image: url(header.jpg); + background-repeat: no-repeat; + background-position: 0 0; + border-bottom: 1px solid #fff; + position: relative; + } + #mainnav + { + background-color: #0EFCEA; + color: #272900; + padding: 2px 0; + margin: 0 0 20px 0; + } + #skipmenu + { + position: absolute; + right: 10px; + top: 5px; + } + #skipmenu a + { + color: #555; + text-decoration: none; + } + #skipmenu a:hover + { + color: #fff; + background-color:#F7F693; + text-decoration: none; + } +#menu + { + float: right; + width: 150px; + } +#menu ul + { + margin-left: 0; + padding-left: 0; + list-style-type: none; + line-height: 165%; + } + #contents + { + margin: 0 170px 40px 20px; + border-right: 1px solid #C5C877; + padding-right: 20px; + } + #contents p { line-height: 165%; } + .imagefloat + { + float: right; + padding: 2px; + border: 1px solid #9FA41D; + margin: 0 0 10px 10px; + } + #footer + { + clear: both; + color: #272900; + background-color: #35F1CF; + text-align: right; + padding: 5px; + font-size: 90%; + } diff --git a/partieWeb/public/page.css b/partieWeb/public/page.css new file mode 100644 index 0000000..0fb77ca --- /dev/null +++ b/partieWeb/public/page.css @@ -0,0 +1,94 @@ +#container + { + margin: 1em auto; + width: 650px; + text-align:left; + background-color:#F7F2E0; + border: 1px solid #676767; + } +#container1 + { + margin: 1em auto; + width: 650px; + text-align:center; + background-color:#F7F2E0; + border: 1px solid #676767; + } +#header + { + height: 53px; + background-image: url(header.jpg); + background-repeat: no-repeat; + background-position: 0 0; + border-bottom: 1px solid #fff; + position: relative; + } + #header2 + { + height: 53px; + text-align:center; + background-image: url(header.jpg); + background-repeat: no-repeat; + background-position: 0 0; + border-bottom: 1px solid #fff; + position: relative; + } + #mainnav + { + background-color: #0EFCEA; + color: #272900; + padding: 2px 0; + margin: 0 0 20px 0; + } + #skipmenu + { + position: absolute; + right: 10px; + top: 5px; + } + #skipmenu a + { + color: #555; + text-decoration: none; + } + #skipmenu a:hover + { + color: #fff; + background-color:#F7F693; + text-decoration: none; + } +#menu + { + float: right; + width: 150px; + } +#menu ul + { + margin-left: 0; + padding-left: 0; + list-style-type: none; + line-height: 165%; + } + #contents + { + margin: 0 170px 40px 20px; + border-right: 1px solid #C5C877; + padding-right: 20px; + } + #contents p { line-height: 165%; } + .imagefloat + { + float: right; + padding: 2px; + border: 1px solid #9FA41D; + margin: 0 0 10px 10px; + } + #footer + { + clear: both; + color: #272900; + background-color: #35F1CF; + text-align: right; + padding: 5px; + font-size: 90%; + } diff --git a/partieWeb/upload_image.php b/partieWeb/upload_image.php new file mode 100644 index 0000000..95900d0 --- /dev/null +++ b/partieWeb/upload_image.php @@ -0,0 +1,51 @@ + + + +
    +
    +'; +if (move_uploaded_file($_FILES['photo']['tmp_name'],$uploadfile)) +{ + echo"La fiche est valide et a été crée avec succés"; +} +echo''; +$file = fopen($nom=$_POST['nom_medoc'].".html","w"); +fwrite($file,"
    "); +fwrite($file,"\r\n"); +fwrite($file,"
    "); +fwrite($file,"\r\n"); +fwrite($file,"
    "); +fwrite($file,"\r\n"); +fwrite($file,"

    "); +fwrite($file,"\r\n"); +fwrite($file,"
    "); +fwrite($file,"\r\n"); +fwrite($file,""); +fwrite($file,"
    "); +fwrite($file,"

    $_POST[nom_medoc]($_POST[molecule])

    "); +fwrite($file,"\r\n"); +fwrite($file,"

    $_POST[nom_medoc]

    "); +fwrite($file,"
    "); +fwrite($file,"

    Posologie

    "); +fwrite($file,"$_POST[posologie]"); +fwrite($file,"

    Indications

    "); +fwrite($file,"$_POST[indic] + +"); +fwrite($file,"
    "); +fwrite ($file,""); +fclose($file); +?> + + + + + \ No newline at end of file -- libgit2 0.21.2