From 4bd6c06c5051275a191eda40177c9cfda842328f Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sun, 12 Jun 2016 18:46:19 +0200 Subject: [PATCH 1/9] =?UTF-8?q?D=C3=A9but=20ajout=20menu=20avec=20=C3=A0?= =?UTF-8?q?=20propos=20et=20aide?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/net/foucry/pilldroid/About.java | 43 +++++++++++++++++++ .../pilldroid/MedicamentListActivity.java | 22 ++++++++++ app/src/main/res/layout/about.xml | 16 +++++++ app/src/main/res/menu/about.xml | 7 +++ app/src/main/res/values/strings.xml | 2 + 5 files changed, 90 insertions(+) create mode 100644 app/src/main/java/net/foucry/pilldroid/About.java create mode 100644 app/src/main/res/layout/about.xml create mode 100644 app/src/main/res/menu/about.xml diff --git a/app/src/main/java/net/foucry/pilldroid/About.java b/app/src/main/java/net/foucry/pilldroid/About.java new file mode 100644 index 0000000..ccd5f05 --- /dev/null +++ b/app/src/main/java/net/foucry/pilldroid/About.java @@ -0,0 +1,43 @@ +package net.foucry.pilldroid; + +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.text.Html; +import android.widget.TextView; + +/** + * Created by jacques on 12/06/16. + */ +public class About extends AppCompatActivity{ + + private final String htmlText = "" + + "

À propos de " + R.string.app_name + "

" + + "" + + ""; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.about); + + TextView htmlTextView = (TextView)findViewById(R.id.aboutHtml); + htmlTextView.setText(Html.fromHtml(htmlText, new ImageGetter(), null)); + } + + private class ImageGetter implements Html.ImageGetter { + + public Drawable getDrawable(String source) { + int id; + if (source.equals("ic_launcher.png")) { + id = R.mipmap.ic_launcher; + } else { + return null; + } + + Drawable d = getResources().getDrawable(id); + d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); + return d; + } + } +} diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java index 0ee95fc..3da720e 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java @@ -11,6 +11,9 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -147,6 +150,25 @@ public class MedicamentListActivity extends AppCompatActivity { } } + + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.about, menu); + return true; + } + + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.about: + startActivity(new Intent(this, About.class)); + return true; + case R.id.help: + //startActivity(new Intent(this, Help.class)); + return true; + } + return super.onOptionsItemSelected(item); + } + public void scanNow(View view) { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); //intent.putExtra("SCAN_MODE", "CODE_128"); diff --git a/app/src/main/res/layout/about.xml b/app/src/main/res/layout/about.xml new file mode 100644 index 0000000..05ed450 --- /dev/null +++ b/app/src/main/res/layout/about.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/about.xml b/app/src/main/res/menu/about.xml new file mode 100644 index 0000000..f25403c --- /dev/null +++ b/app/src/main/res/menu/about.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cb93174..d0c5ac7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -126,4 +126,6 @@ Google Book Search Requesting connection to network\u2026 Médicament introuvable dans la base de données + À propos + Aide From 9da83c3f337f02ebf17de1ed64d060c5cc54cf7d Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Tue, 14 Jun 2016 16:56:40 +0200 Subject: [PATCH 2/9] =?UTF-8?q?Correction=20erreur=20sur=20la=20copy/lectu?= =?UTF-8?q?re=20de=20la=20base=20de=20m=C3=A9dicaments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/net/foucry/pilldroid/DBMedoc.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/DBMedoc.java b/app/src/main/java/net/foucry/pilldroid/DBMedoc.java index e15488f..a446765 100644 --- a/app/src/main/java/net/foucry/pilldroid/DBMedoc.java +++ b/app/src/main/java/net/foucry/pilldroid/DBMedoc.java @@ -47,14 +47,13 @@ public class DBMedoc extends SQLiteOpenHelper{ } public void createDatabase() throws IOException { - Log.e(MedicamentListActivity.Constants.TAG, "createDatabase called"); boolean dbExist = checkDatabase(); if (dbExist) { - // Nothing to do, DB already exist + Log.v("DB Exists", "db exists"); } else { - this.getDatabaseName(); + this.getReadableDatabase(); try { copyDatabase(); } catch (IOException e) { From 2c5025985e419d863b1c8285a59b03186548b72c Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Tue, 14 Jun 2016 23:36:07 +0200 Subject: [PATCH 3/9] Ajout de About dqans le Manufest --- app/src/main/AndroidManifest.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2580491..35525ae 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,6 +43,11 @@ + + \ No newline at end of file From 70db53306046792b74ce36b350d876383ff59dea Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Tue, 14 Jun 2016 23:41:05 +0200 Subject: [PATCH 4/9] About avec HTML (mais sans image) --- .../main/java/net/foucry/pilldroid/About.java | 10 +++++++--- app/src/main/res/layout/about.xml | 8 +------- app/src/main/res/values/strings.xml | 20 +++++++++++++++++++ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/About.java b/app/src/main/java/net/foucry/pilldroid/About.java index ccd5f05..6a68da4 100644 --- a/app/src/main/java/net/foucry/pilldroid/About.java +++ b/app/src/main/java/net/foucry/pilldroid/About.java @@ -4,7 +4,8 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.text.Html; -import android.widget.TextView; +import android.text.Spanned; +import android.webkit.WebView; /** * Created by jacques on 12/06/16. @@ -21,8 +22,11 @@ public class About extends AppCompatActivity{ super.onCreate(savedInstanceState); setContentView(R.layout.about); - TextView htmlTextView = (TextView)findViewById(R.id.aboutHtml); - htmlTextView.setText(Html.fromHtml(htmlText, new ImageGetter(), null)); + String htmlAsString = getString(R.string.html); + Spanned htmlAsSpanned = Html.fromHtml(htmlAsString); + + WebView webView = (WebView) findViewById(R.id.aboutHtml); + webView.loadDataWithBaseURL(null, htmlAsString, "text/html", "utf-8", null); } private class ImageGetter implements Html.ImageGetter { diff --git a/app/src/main/res/layout/about.xml b/app/src/main/res/layout/about.xml index 05ed450..234323c 100644 --- a/app/src/main/res/layout/about.xml +++ b/app/src/main/res/layout/about.xml @@ -3,13 +3,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d0c5ac7..9ee4201 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -128,4 +128,24 @@ Médicament introuvable dans la base de données À propos Aide + + À propos de PillDroid +

Gestion de stock de médicaments

+

This is some html. Look, here\'s an underline.

+

Look, this is emphasized. And here\'s some bold.

+

This is a UL list: +

    +
  • One
  • +
  • Two
  • +
  • Three
  • +
+

This is an OL list: +

    +
  1. One
  2. +
  3. Two
  4. +
  5. Three
  6. +
+ ]]> +
From 1efe5fd245ead0e27664a10e79ca1ad6eddc07fb Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sun, 19 Jun 2016 00:57:40 +0200 Subject: [PATCH 5/9] =?UTF-8?q?Nouvelle=20fa=C3=A7on=20de=20lire=20et=20af?= =?UTF-8?q?ficher=20about?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/about.html | 17 +++++++ .../main/java/net/foucry/pilldroid/About.java | 44 +++++++++++++++---- app/src/main/res/layout/about.xml | 2 +- app/src/main/res/values/strings.xml | 20 --------- 4 files changed, 54 insertions(+), 29 deletions(-) create mode 100644 app/src/main/assets/about.html diff --git a/app/src/main/assets/about.html b/app/src/main/assets/about.html new file mode 100644 index 0000000..757779c --- /dev/null +++ b/app/src/main/assets/about.html @@ -0,0 +1,17 @@ +

À propos de PillDroid

+

Gestion de stock de médicaments

+

This is some html. Look, here\'s an underline.

+

Look, this is emphasized. And here\'s some bold.

+

This is a UL list: +

    +
  • One
  • +
  • Two
  • +
  • Three
  • +
+

This is an OL list: +

    +
  1. One
  2. +
  3. Two
  4. +
  5. Three
  6. +
+ \ No newline at end of file diff --git a/app/src/main/java/net/foucry/pilldroid/About.java b/app/src/main/java/net/foucry/pilldroid/About.java index 6a68da4..45b0987 100644 --- a/app/src/main/java/net/foucry/pilldroid/About.java +++ b/app/src/main/java/net/foucry/pilldroid/About.java @@ -2,31 +2,58 @@ package net.foucry.pilldroid; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.support.v4.content.res.ResourcesCompat; import android.support.v7.app.AppCompatActivity; import android.text.Html; import android.text.Spanned; +import android.util.Log; import android.webkit.WebView; +import android.widget.TextView; + +import java.io.IOException; +import java.io.InputStream; /** * Created by jacques on 12/06/16. */ public class About extends AppCompatActivity{ - private final String htmlText = "" + - "

À propos de " + R.string.app_name + "

" + - "" + - ""; + private WebView aboutView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about); - String htmlAsString = getString(R.string.html); - Spanned htmlAsSpanned = Html.fromHtml(htmlAsString); + String htmlString = null; - WebView webView = (WebView) findViewById(R.id.aboutHtml); - webView.loadDataWithBaseURL(null, htmlAsString, "text/html", "utf-8", null); +/* aboutView = (WebView) findViewById(R.id.aboutHtml); + + aboutView.loadUrl("file:///android_asset/about.html"); + aboutView.clearCache(true); + aboutView.clearHistory(); + aboutView.getSettings().setJavaScriptEnabled(true); + aboutView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);*/ + + try { + InputStream is = getAssets().open("about.html"); + int size = is.available(); + + byte[] buffer = new byte[size]; + + is.read(buffer); + is.close(); + + htmlString = new String(buffer); + + } catch (IOException e) { + throw new RuntimeException(e); + } + + TextView htmlTextView = (TextView)findViewById(R.id.aboutHtml); + htmlTextView.setText(Html.fromHtml(htmlString, new ImageGetter(), null)); + + Log.i("PillDroid", htmlTextView.getText().toString()); } private class ImageGetter implements Html.ImageGetter { @@ -40,6 +67,7 @@ public class About extends AppCompatActivity{ } Drawable d = getResources().getDrawable(id); +// Drawable d = ResourcesCompat.getDrawable(getResources(),id, null); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); return d; } diff --git a/app/src/main/res/layout/about.xml b/app/src/main/res/layout/about.xml index 234323c..54a2cca 100644 --- a/app/src/main/res/layout/about.xml +++ b/app/src/main/res/layout/about.xml @@ -3,7 +3,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9ee4201..d0c5ac7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -128,24 +128,4 @@ Médicament introuvable dans la base de données À propos Aide - - À propos de PillDroid -

Gestion de stock de médicaments

-

This is some html. Look, here\'s an underline.

-

Look, this is emphasized. And here\'s some bold.

-

This is a UL list: -

    -
  • One
  • -
  • Two
  • -
  • Three
  • -
-

This is an OL list: -

    -
  1. One
  2. -
  3. Two
  4. -
  5. Three
  6. -
- ]]> -
From fe3a1fef56f4d9c195e96300111d4f14aba2f7d0 Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sun, 19 Jun 2016 01:46:37 +0200 Subject: [PATCH 6/9] Utilisation du html de PilStock --- app/src/main/assets/about.html | 49 ++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/app/src/main/assets/about.html b/app/src/main/assets/about.html index 757779c..a15b457 100644 --- a/app/src/main/assets/about.html +++ b/app/src/main/assets/about.html @@ -1,17 +1,32 @@ -

À propos de PillDroid

-

Gestion de stock de médicaments

-

This is some html. Look, here\'s an underline.

-

Look, this is emphasized. And here\'s some bold.

-

This is a UL list: -

    -
  • One
  • -
  • Two
  • -
  • Three
  • -
-

This is an OL list: -

    -
  1. One
  2. -
  3. Two
  4. -
  5. Three
  6. -
- \ No newline at end of file + + + + + + +
+ +
PilStock © 2016 Jacques Foucry
+

PilStock est une gestion théorique de votre stock de médicaments.

+

PilStock n'a aucune connaissance des interactions des médicaments entre eux.

+

EN CAS DE DOUTE, CONSULTEZ VOTRE MÉDECIN OU VOTRE PHARMACIEN.

+

PilStock ne vous rappelle pas de prendre vos médicaments.

+

LA RESPONSABILITÉ DE L'AUTEUR NE SAURAIT ÊTRE ENGAGÉE EN CAS DE SURDOSAGE OU D'OUBLI DE PRISE.

+
+

PilStock n'aurait pas pu voir le jour sans les conseils avisés de Frank, Benoit, Dominique & Aurélien.

+

Stéphane en grand chamboulateur d'interface en fait quelque chose d'utilisable

+
+

Le soutien actif et les conseils du Dr Kauffmann me permettent de faire évoluer PilStock

+

Vous pouvez me contacter à l'adresse suivante : pilstock@pilstock-app.com

+ + From 3a0e0e1301721c5e85215ac919790ba0dceb8f22 Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sun, 19 Jun 2016 01:47:30 +0200 Subject: [PATCH 7/9] Code de chargement et affichage de la page About --- .../main/java/net/foucry/pilldroid/About.java | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/About.java b/app/src/main/java/net/foucry/pilldroid/About.java index 45b0987..ced9973 100644 --- a/app/src/main/java/net/foucry/pilldroid/About.java +++ b/app/src/main/java/net/foucry/pilldroid/About.java @@ -1,17 +1,11 @@ package net.foucry.pilldroid; +import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.support.v4.content.res.ResourcesCompat; import android.support.v7.app.AppCompatActivity; import android.text.Html; -import android.text.Spanned; -import android.util.Log; import android.webkit.WebView; -import android.widget.TextView; - -import java.io.IOException; -import java.io.InputStream; /** * Created by jacques on 12/06/16. @@ -27,33 +21,16 @@ public class About extends AppCompatActivity{ String htmlString = null; -/* aboutView = (WebView) findViewById(R.id.aboutHtml); + aboutView = (WebView) findViewById(R.id.aboutHtml); aboutView.loadUrl("file:///android_asset/about.html"); aboutView.clearCache(true); aboutView.clearHistory(); aboutView.getSettings().setJavaScriptEnabled(true); - aboutView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);*/ + aboutView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); + aboutView.setBackgroundColor(Color.WHITE); - try { - InputStream is = getAssets().open("about.html"); - int size = is.available(); - byte[] buffer = new byte[size]; - - is.read(buffer); - is.close(); - - htmlString = new String(buffer); - - } catch (IOException e) { - throw new RuntimeException(e); - } - - TextView htmlTextView = (TextView)findViewById(R.id.aboutHtml); - htmlTextView.setText(Html.fromHtml(htmlString, new ImageGetter(), null)); - - Log.i("PillDroid", htmlTextView.getText().toString()); } private class ImageGetter implements Html.ImageGetter { From ee19aad0cfbf8c3013ac891284e1f172137eb111 Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sun, 19 Jun 2016 01:48:04 +0200 Subject: [PATCH 8/9] Ajout de la couleur de fond --- app/src/main/res/layout/about.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/about.xml b/app/src/main/res/layout/about.xml index 54a2cca..1dd71d4 100644 --- a/app/src/main/res/layout/about.xml +++ b/app/src/main/res/layout/about.xml @@ -1,9 +1,10 @@ + android:layout_height="match_parent" + android:background="@android:color/white"> - From c3b87c15344aa796066e812c38b19c790a05f79c Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sun, 19 Jun 2016 01:48:41 +0200 Subject: [PATCH 9/9] Ajout de la barre de navigation pour le retour de About --- app/src/main/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 35525ae..79a7284 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -44,9 +44,9 @@ + android:theme="@style/AppTheme">