From 4bd6c06c5051275a191eda40177c9cfda842328f Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Sun, 12 Jun 2016 18:46:19 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20ajout=20menu=20avec=20=C3=A0=20pro?= =?UTF-8?q?pos=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