diff --git a/app/build.gradle b/app/build.gradle
index 10f9640..5f71d96 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,13 +2,14 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 29
+ compileSdkVersion 28
defaultConfig {
applicationId "net.foucry.pilldroid"
- minSdkVersion 27
- targetSdkVersion 29
- versionCode 1
+ minSdkVersion defaultMinSdkVersion
+ targetSdkVersion defaultTargetSdkVersion
+ versionCode defaultVersionCode1
versionName "1.0"
+ applicationIdSuffix = 'alpha'
}
buildTypes {
release {
@@ -26,20 +27,32 @@ android {
incremental false
}*/
buildToolsVersion = buildToolsVersion1
-}
-
-repositories {
- mavenCentral()
- maven {
- url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"
+ allprojects {
+ tasks.withType(JavaCompile) {
+ options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
+ }
}
}
+repositories {
+ jcenter()
+}
+sourceSets {
+ main {
+ java {
+ exclude 'net/foucry/pilldroid/scanActivity.java'
+ }
+ }
+}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.13'
- implementation 'com.android.support:appcompat-v7:27.1.1'
- implementation 'com.android.support:recyclerview-v7:27.1.1'
- implementation 'com.android.support:design:27.1.1'
- implementation 'com.android.support:support-v4:27.1.1'
-}
\ No newline at end of file
+
+ implementation 'androidx.appcompat:appcompat:1.0.0'
+ implementation 'androidx.recyclerview:recyclerview:1.0.0'
+ implementation 'com.google.android.material:material:1.0.0'
+ implementation 'androidx.legacy:legacy-support-v4:1.0.0'
+
+ implementation 'com.journeyapps:zxing-android-embedded:4.1.0'
+ implementation 'androidx.appcompat:appcompat:1.0.0'
+}
diff --git a/app/libs/android-core-3.2.2-SNAPSHOT.jar b/app/libs/android-core-3.2.2-SNAPSHOT.jar
deleted file mode 100644
index 503f817..0000000
Binary files a/app/libs/android-core-3.2.2-SNAPSHOT.jar and /dev/null differ
diff --git a/app/libs/core-3.2.2-SNAPSHOT.jar b/app/libs/core-3.2.2-SNAPSHOT.jar
deleted file mode 100644
index 4ed7e27..0000000
Binary files a/app/libs/core-3.2.2-SNAPSHOT.jar and /dev/null differ
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5417295..31d9fdc 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -2,14 +2,21 @@
-
-
+
+
+
+
-
-
-
+
+
+
-
-
+
+
+
-
- -->
+
-
+ android:theme="@style/AppTheme" />
+
+
-
+
+
+
\ 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 d03042a..c9497da 100644
--- a/app/src/main/java/net/foucry/pilldroid/About.java
+++ b/app/src/main/java/net/foucry/pilldroid/About.java
@@ -1,11 +1,10 @@
package net.foucry.pilldroid;
-import net.foucry.pilldroid.R;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+import androidx.appcompat.app.AppCompatActivity;
import android.text.Html;
import android.webkit.WebView;
diff --git a/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java b/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java
new file mode 100644
index 0000000..fff456d
--- /dev/null
+++ b/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java
@@ -0,0 +1,144 @@
+package net.foucry.pilldroid;
+
+import android.app.Activity;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageButton;
+
+import androidx.annotation.NonNull;
+
+import com.journeyapps.barcodescanner.CaptureManager;
+import com.journeyapps.barcodescanner.DecoratedBarcodeView;
+import com.journeyapps.barcodescanner.ViewfinderView;
+
+import java.util.Random;
+
+/**
+ * Custom Scanner Activity extending from Activity to display a custom layout form scanner view.
+ */
+public class CustomScannerActivity extends Activity implements
+ DecoratedBarcodeView.TorchListener {
+
+ private CaptureManager capture;
+ private DecoratedBarcodeView barcodeScannerView;
+ private Button switchFlashlightButton;
+ private ViewfinderView viewfinderView;
+ private ImageButton cancelButton;
+ private ImageButton keyboardButton;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_custom_scanner);
+
+ barcodeScannerView = findViewById(R.id.zxing_barcode_scanner);
+ barcodeScannerView.setTorchListener(this);
+
+ cancelButton = findViewById(R.id.cancel_button);
+ keyboardButton = findViewById(R.id.keyboard_button);
+
+ switchFlashlightButton = findViewById(R.id.switch_flashlight);
+
+ viewfinderView = findViewById(R.id.zxing_viewfinder_view);
+
+ // if the device does not have flashlight in its camera,
+ // then remove the switch flashlight button...
+ if (!hasFlash()) {
+ switchFlashlightButton.setVisibility(View.GONE);
+ }
+
+ capture = new CaptureManager(this, barcodeScannerView);
+ capture.initializeFromIntent(getIntent(), savedInstanceState);
+ capture.setShowMissingCameraPermissionDialog(false);
+ capture.decode();
+
+ changeMaskColor(null);
+ changeLaserVisibility(true);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ capture.onResume();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ capture.onPause();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ capture.onDestroy();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ capture.onSaveInstanceState(outState);
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ return barcodeScannerView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
+ }
+
+ /**
+ * Check if the device's camera has a Flashlight.
+ * @return true if there is Flashlight, otherwise false.
+ */
+ private boolean hasFlash() {
+ return getApplicationContext().getPackageManager()
+ .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
+ }
+
+ public void switchFlashlight(View view) {
+ if (getString(R.string.turn_on_flashlight).contentEquals(switchFlashlightButton.getText())) {
+ barcodeScannerView.setTorchOn();
+ } else {
+ barcodeScannerView.setTorchOff();
+ }
+ }
+
+ public void changeMaskColor(View view) {
+ Random rnd = new Random();
+ int color = Color.argb(100, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
+ viewfinderView.setMaskColor(color);
+ }
+
+ public void changeLaserVisibility(boolean visible) {
+ viewfinderView.setLaserVisibility(visible);
+ }
+
+ @Override
+ public void onTorchOn() {
+ switchFlashlightButton.setText(R.string.turn_off_flashlight);
+ }
+
+ @Override
+ public void onTorchOff() {
+ switchFlashlightButton.setText(R.string.turn_on_flashlight);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ capture.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ }
+
+
+ public void onKeyboard(View view) {
+ setResult(3);
+ finish();
+ }
+
+ public void onCancel(View view) {
+ setResult(2);
+ finish();
+ }
+}
diff --git a/app/src/main/java/net/foucry/pilldroid/DBHelper.java b/app/src/main/java/net/foucry/pilldroid/DBHelper.java
index 3600331..f75746f 100644
--- a/app/src/main/java/net/foucry/pilldroid/DBHelper.java
+++ b/app/src/main/java/net/foucry/pilldroid/DBHelper.java
@@ -41,7 +41,7 @@ class DBHelper extends SQLiteOpenHelper {
public static synchronized DBHelper getInstance(Context context) {
if (sInstance == null) {
- sInstance = new DBHelper(context.getApplicationContext());
+ sInstance = new DBHelper(context);
}
return sInstance;
}
@@ -286,12 +286,6 @@ class DBHelper extends SQLiteOpenHelper {
Log.d(TAG, "Return update = " + i);
// Close DB
db.close();
-
- // DEBUG
- Medicament toto = getDrug(medicament.getId());
- Log.d(TAG, "toto stock== " + toto.getStock());
-
-
}
/**
diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java
index b1db584..4309c15 100644
--- a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java
+++ b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailActivity.java
@@ -2,15 +2,16 @@ package net.foucry.pilldroid;
import android.content.Intent;
import android.os.Bundle;
-import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.Snackbar;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.snackbar.Snackbar;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
+import android.widget.ImageButton;
import android.widget.TextView;
import static net.foucry.pilldroid.R.id.detail_toolbar;
@@ -36,6 +37,7 @@ public class MedicamentDetailActivity extends AppCompatActivity {
medicament = (Medicament) extras.getSerializable("medicament");
+ assert medicament != null;
Log.d(TAG, "medicament == " + medicament.toString());
setContentView(R.layout.activity_medicament_detail);
@@ -46,7 +48,7 @@ public class MedicamentDetailActivity extends AppCompatActivity {
setSupportActionBar(toolbar);
}
- FloatingActionButton fab = findViewById(R.id.fab);
+ ImageButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java
index f1b2f08..7ad4678 100644
--- a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java
+++ b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java
@@ -1,17 +1,15 @@
package net.foucry.pilldroid;
-import android.annotation.SuppressLint;
import android.app.Activity;
-import android.content.Context;
-import android.support.design.widget.CollapsingToolbarLayout;
+
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.util.Log;
+import androidx.fragment.app.Fragment;
+
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
-import android.widget.Toast;
/**
* A fragment representing a single Medicament detail screen.
@@ -76,43 +74,43 @@ public class MedicamentDetailFragment extends Fragment {
nameView = detailView.findViewById(R.id.name_cell);
TextView nameLabel = nameView.findViewById(R.id.label);
TextView nameValeur = nameView.findViewById(R.id.valeur);
- nameLabel.setText("Nom");
+ nameLabel.setText(R.string.med_name_label);
nameValeur.setText(medicament.getNom());
presentationView = detailView.findViewById(R.id.presentation_cell);
TextView presentationLabel = presentationView.findViewById(R.id.label);
TextView presentationValeur = presentationView.findViewById(R.id.valeur);
- presentationLabel.setText("Presentation");
+ presentationLabel.setText(R.string.med_presention_labal);
presentationValeur.setText(medicament.getPresentation());
adminModeView = detailView.findViewById(R.id.administration_cell);
TextView adminModeLabel = adminModeView.findViewById(R.id.label);
TextView adminModeValeur = adminModeView.findViewById(R.id.valeur);
- adminModeLabel.setText("Mode d'administration");
+ adminModeLabel.setText(R.string.med_administationMode_label);
adminModeValeur.setText(medicament.getMode_administration());
stockView = detailView.findViewById(R.id.stock_cell);
TextView stockLibelle = (stockView.findViewById(R.id.libelle));
TextView stockValue = stockView.findViewById(R.id.valeur);
- stockLibelle.setText("Stock courant");
+ stockLibelle.setText(R.string.med_current_stock_label);
stockValue.setText(Double.toString(medicament.getStock()));
priseView = detailView.findViewById(R.id.prise_cell);
TextView priseLibelle = priseView.findViewById(R.id.libelle);
TextView priseValue = (priseView.findViewById(R.id.valeur));
- priseLibelle.setText("Prise");
+ priseLibelle.setText(R.string.med_take_label);
priseValue.setText(Double.toString(medicament.getPrise()));
warningView = detailView.findViewById(R.id.warning_cell);
TextView warningLibelle = warningView.findViewById(R.id.libelle);
TextView warningValue = warningView.findViewById(R.id.valeur);
- warningLibelle.setText("Seuil d'alerte");
+ warningLibelle.setText(R.string.med_warningTherehold_label);
warningValue.setText(Integer.toString(medicament.getWarnThreshold()));
alertView = detailView.findViewById(R.id.alert_cell);
TextView alertLibelle = alertView.findViewById(R.id.libelle);
TextView alertValue = alertView.findViewById(R.id.valeur);
- alertLibelle.setText("Seuil critique");
+ alertLibelle.setText(R.string.med_criticalTherehold_label);
alertValue.setText(Integer.toString(medicament.getAlertThreshold()));
}
diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java
index 2baa9a7..9dab72d 100644
--- a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java
+++ b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java
@@ -5,18 +5,17 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.SystemClock;
-import android.support.annotation.NonNull;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.Toolbar;
+import androidx.annotation.NonNull;
+import androidx.core.app.NotificationCompat;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -37,6 +36,10 @@ import java.util.List;
import java.util.Locale;
import java.util.Random;
+import com.google.zxing.client.android.Intents;
+import com.google.zxing.integration.android.IntentIntegrator;
+import com.google.zxing.integration.android.IntentResult;
+
import static net.foucry.pilldroid.NotificationPublisher.NOTIFICATION_ID;
import static net.foucry.pilldroid.UtilDate.date2String;
import static net.foucry.pilldroid.Utils.intRandomExclusive;
@@ -51,6 +54,7 @@ import static net.foucry.pilldroid.Utils.intRandomExclusive;
*/
public class MedicamentListActivity extends AppCompatActivity {
+ private static final String CHANNEL_ID = "MedicamentCHANEL";
/**
* Whether or not the activity is in two-pane mode, i.e. running on a tablet
* device.
@@ -61,6 +65,8 @@ public class MedicamentListActivity extends AppCompatActivity {
final Boolean DEMO = false;
final Boolean DBDEMO = false;
final static Random random = new Random();
+ public final int CUSTOMIZED_REQUEST_CODE = 0x0000ffff;
+ public final int SAVE_RQUEST_CODE = 0x000000ff;
@Override
public void onStart() {
@@ -85,7 +91,6 @@ public class MedicamentListActivity extends AppCompatActivity {
private List medicaments;
- private View mRecyclerView;
private SimpleItemRecyclerViewAdapter mAdapter;
public int getCount() {
@@ -96,6 +101,36 @@ public class MedicamentListActivity extends AppCompatActivity {
return medicaments.get(position);
}
+ public void constructMedsList()
+ {
+ Medicament currentMedicament;
+ dbHelper = new DBHelper(getApplicationContext());
+
+ if (!(medicaments == null)) {
+ if (!medicaments.isEmpty()) {
+ medicaments.clear();
+ }
+ }
+ medicaments = dbHelper.getAllDrugs();
+
+ Collections.sort(medicaments, new Comparator() {
+ @Override
+ public int compare(Medicament lhs, Medicament rhs) {
+ return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
+ }
+ });
+
+ for (int position = 0 ; position < this.getCount() ; position++ ) {
+ currentMedicament = this.getItem(position);
+ currentMedicament.newStock(currentMedicament.getStock());
+ dbHelper.updateDrug(currentMedicament);
+ }
+
+ View mRecyclerView = findViewById(R.id.medicament_list);
+ assert mRecyclerView != null;
+ setupRecyclerView((RecyclerView) mRecyclerView);
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -160,20 +195,7 @@ public class MedicamentListActivity extends AppCompatActivity {
}
}
- if (medicaments == null) {
- medicaments = dbHelper.getAllDrugs();
-
- Collections.sort(medicaments, new Comparator() {
- @Override
- public int compare(Medicament lhs, Medicament rhs) {
- return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
- }
- });
- }
-
- mRecyclerView = findViewById(R.id.medicament_list);
- assert mRecyclerView != null;
- setupRecyclerView((RecyclerView) mRecyclerView);
+ constructMedsList();
if (findViewById(R.id.medicament_detail_container) != null) {
// The detail container view will be present only in the
@@ -216,28 +238,24 @@ public class MedicamentListActivity extends AppCompatActivity {
* call ZXing Library to scan a new QR/EAN code
*/
public void scanNow(View view) {
- Intent intent = new Intent("com.google.zxing.client.android.SCAN");
- //intent.putExtra("SCAN_MODE", "CODE_128");
- intent.putExtra("SCAN_FORMATS", "CODE_18,DATA_MATRIX");
- startActivityForResult(intent, 0);
+ // new IntentIntegrator(this).initiateScan(); Simpliest way
+
+/* IntentIntegrator integrator = new IntentIntegrator(this);
+ integrator.setDesiredBarcodeFormats(IntentIntegrator.CODE_128, IntentIntegrator.DATA_MATRIX);
+ integrator.setPrompt("Scanner un Médicament");
+ integrator.setCameraId(0); // Use a specific camera of the device
+ integrator.setBeepEnabled(true);
+ integrator.setBarcodeImageEnabled(false);
+ integrator.initiateScan();*/
+
+ // new IntentIntegrator(this).setOrientationLocked(false).setCaptureActivity(scanActivity.class).initiateScan();
+ new IntentIntegrator(this).setOrientationLocked(false).setCaptureActivity(CustomScannerActivity.class).initiateScan();
}
/**
* Calculation of newStock
*/
public void newStockCalculation() {
-
- Medicament currentMedicament;
- dbHelper = new DBHelper(this);
-
- for (int position = 0 ; position < this. getCount() ; position++ ) {
- currentMedicament = this.getItem(position);
- currentMedicament.newStock(currentMedicament.getStock());
- dbHelper.updateDrug(currentMedicament);
- }
-
-// TODO: si un des médicaments est en rouge, on déclanche une notification visuelle pour dans 5 secondes
-
Calendar calendar = Calendar.getInstance();
Date now = calendar.getTime();
@@ -260,70 +278,36 @@ public class MedicamentListActivity extends AppCompatActivity {
Log.d(TAG, "Notification scheduled for "+ UtilDate.convertDate(dateSchedule));
}
- public void onActivityResult(int requestCode, int resultCode, Intent intent) {
- Context context = getApplicationContext();
- String cip13;
- if (requestCode == 0) {
- if (resultCode == RESULT_OK) {
- String contents = intent.getStringExtra("SCAN_RESULT");
- String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
- Log.i(TAG, "Format:" + format);
- Log.i(TAG, "Content:" + contents);
-
- AlertDialog.Builder dlg = new AlertDialog.Builder(this);
- dlg.setTitle(context.getString(R.string.app_name));
-
- // Handle successful scan
- assert format != null;
- if (format.equals("CODE_128")) { //CODE_128
- cip13 = contents;
- } else {
- assert contents != null;
- cip13 = contents.substring(4, 17);
- }
-
- dbMedoc.openDatabase();
- final Medicament scannedMedoc = dbMedoc.getMedocByCIP13(cip13);
- dbMedoc.close();
-
- if (scannedMedoc != null) {
- String msg = scannedMedoc.getNom() + " " + getString(R.string.msgFound);
-
- dlg.setMessage(msg);
- dlg.setNegativeButton(context.getString(R.string.button_cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // Nothing to do in case of cancel
- }
- });
- dlg.setPositiveButton(context.getString(R.string.button_ok), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // Add Medicament to DB then try to show it
- scannedMedoc.setDateEndOfStock();
- dbHelper.addDrug(scannedMedoc);
- mAdapter.addItem(scannedMedoc);
- }
- });
- dlg.show();
- } else {
- dlg.setMessage(context.getString(R.string.msgNotFound));
- dlg.setPositiveButton("OK", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // nothing to do to just dismiss dialog
- }
- });
-
- }
- } else if (resultCode == RESULT_CANCELED) {
- // Handle cancel
- Toast.makeText(context, "Scan annulé", Toast.LENGTH_LONG).show();
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode != CUSTOMIZED_REQUEST_CODE && requestCode != IntentIntegrator.REQUEST_CODE) {
+ // This is important, otherwise the result will not be passed to the fragment
+ super.onActivityResult(requestCode, resultCode, data);
+ return;
+ }
+ switch (requestCode) {
+ case CUSTOMIZED_REQUEST_CODE: {
+ Toast.makeText(this, "REQUEST_CODE = " + requestCode, Toast.LENGTH_LONG).show();
+ break;
}
- } else if (requestCode == 1){
- Toast.makeText(context, "back from detail", Toast.LENGTH_SHORT).show();
- // TODO : Si requestCode=1 -> Sauvegarde du medoc dans la base et
- // TODO : raffraichissement de la base.[Call updateDrug(medicament)]
+ default:
+ break;
+ }
+
+ IntentResult result = IntentIntegrator.parseActivityResult(resultCode, data);
+
+ if(result.getContents() == null) {
+ Intent originalIntent = result.getOriginalIntent();
+ if (originalIntent == null) {
+ Log.d(TAG, "Cancelled scan");
+ Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
+ } else if(originalIntent.hasExtra(Intents.Scan.MISSING_CAMERA_PERMISSION)) {
+ Log.d(TAG,"Cancelled scan due to missing camera permission");
+ Toast.makeText(this, "Cancelled due to missing camera permission", Toast.LENGTH_LONG).show();
+ }
+ } else {
+ Log.d(TAG, "Scanned");
+ Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
}
}
@@ -351,11 +335,12 @@ public class MedicamentListActivity extends AppCompatActivity {
private Notification getNotification(String content) {
Log.i(TAG, "getNotification");
- Notification.Builder builder = new Notification.Builder(this);
- builder.setContentTitle(getAppName());
- builder.setContentText(content);
- builder.setSmallIcon(R.drawable.ic_pill);
- builder.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(),
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
+ .setContentTitle(getAppName())
+ .setContentText(content)
+ .setSmallIcon(R.drawable.ic_pill)
+ .setAutoCancel(true)
+ .setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(),
R.mipmap.ic_launcher));
return builder.build();
}
@@ -451,6 +436,7 @@ public class MedicamentListActivity extends AppCompatActivity {
});
}
+
@Override
public int getItemCount() {
return mValues.size();
@@ -482,3 +468,70 @@ public class MedicamentListActivity extends AppCompatActivity {
}
}
}
+
+/*
+ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
+ Context context = getApplicationContext();
+ String cip13;
+ if (requestCode == 0) {
+ if (resultCode == RESULT_OK) {
+ String contents = intent.getStringExtra("SCAN_RESULT");
+ String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
+ Log.i(TAG, "Format:" + format);
+ Log.i(TAG, "Content:" + contents);
+
+ AlertDialog.Builder dlg = new AlertDialog.Builder(this);
+ dlg.setTitle(context.getString(R.string.app_name));
+
+ // Handle successful scan
+ assert format != null;
+ if (format.equals("CODE_128")) { //CODE_128
+ cip13 = contents;
+ } else {
+ assert contents != null;
+ cip13 = contents.substring(4, 17);
+ }
+
+ dbMedoc.openDatabase();
+ final Medicament scannedMedoc = dbMedoc.getMedocByCIP13(cip13);
+ dbMedoc.close();
+
+ if (scannedMedoc != null) {
+ String msg = scannedMedoc.getNom() + " " + getString(R.string.msgFound);
+
+ dlg.setMessage(msg);
+ dlg.setNegativeButton(context.getString(R.string.button_cancel), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // Nothing to do in case of cancel
+ }
+ });
+ dlg.setPositiveButton(context.getString(R.string.button_ok), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // Add Medicament to DB then try to show it
+ scannedMedoc.setDateEndOfStock();
+ dbHelper.addDrug(scannedMedoc);
+ mAdapter.addItem(scannedMedoc);
+ }
+ });
+ dlg.show();
+ } else {
+ dlg.setMessage(context.getString(R.string.msgNotFound));
+ dlg.setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // nothing to do to just dismiss dialog
+ }
+ });
+ }
+ } else if (resultCode == RESULT_CANCELED) {
+ // Handle cancel
+ Toast.makeText(context, "Scan annulé", Toast.LENGTH_LONG).show();
+ }
+ } else if (requestCode == 1){
+ Toast.makeText(context, "back from detail", Toast.LENGTH_SHORT).show();
+ constructMedsList();
+ }
+ }
+ */
\ No newline at end of file
diff --git a/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java b/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java
index c536eee..55a832b 100644
--- a/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java
+++ b/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java
@@ -5,6 +5,7 @@ import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.os.VibrationEffect;
import android.os.Vibrator;
import android.util.Log;
@@ -28,9 +29,7 @@ public class NotificationPublisher extends BroadcastReceiver {
notificationManager.notify(id, notification);
}
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
- if (vibrator != null) {
- vibrator.vibrate(400);
- }
-
+ assert vibrator != null;
+ vibrator.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE));
}
}
diff --git a/app/src/main/java/net/foucry/pilldroid/SimpleDividerItemDecoration.java b/app/src/main/java/net/foucry/pilldroid/SimpleDividerItemDecoration.java
index f5206ad..e5d87d1 100644
--- a/app/src/main/java/net/foucry/pilldroid/SimpleDividerItemDecoration.java
+++ b/app/src/main/java/net/foucry/pilldroid/SimpleDividerItemDecoration.java
@@ -3,7 +3,7 @@ package net.foucry.pilldroid;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
/**
diff --git a/app/src/main/res/drawable/ic_add_circle_black_24dp.xml b/app/src/main/res/drawable/ic_add_circle_black_24dp.xml
new file mode 100644
index 0000000..db4e035
--- /dev/null
+++ b/app/src/main/res/drawable/ic_add_circle_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_cancel_black_24dp.xml b/app/src/main/res/drawable/ic_cancel_black_24dp.xml
new file mode 100644
index 0000000..7fd89b0
--- /dev/null
+++ b/app/src/main/res/drawable/ic_cancel_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_keyboard_black_24dp.xml b/app/src/main/res/drawable/ic_keyboard_black_24dp.xml
new file mode 100644
index 0000000..9cb354d
--- /dev/null
+++ b/app/src/main/res/drawable/ic_keyboard_black_24dp.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_reticule_rouge.xml b/app/src/main/res/drawable/ic_reticule_rouge.xml
new file mode 100644
index 0000000..6c8e02b
--- /dev/null
+++ b/app/src/main/res/drawable/ic_reticule_rouge.xml
@@ -0,0 +1,7 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_reticule_vert.xml b/app/src/main/res/drawable/ic_reticule_vert.xml
new file mode 100644
index 0000000..f8d0204
--- /dev/null
+++ b/app/src/main/res/drawable/ic_reticule_vert.xml
@@ -0,0 +1,7 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_save_black_24dp.xml b/app/src/main/res/drawable/ic_save_black_24dp.xml
index a561d63..085eb41 100644
--- a/app/src/main/res/drawable/ic_save_black_24dp.xml
+++ b/app/src/main/res/drawable/ic_save_black_24dp.xml
@@ -1,9 +1,4 @@
-
-
+
+
diff --git a/app/src/main/res/layout-w900dp/medicament_list.xml b/app/src/main/res/layout-w900dp/medicament_list.xml
index 563f006..f003192 100644
--- a/app/src/main/res/layout-w900dp/medicament_list.xml
+++ b/app/src/main/res/layout-w900dp/medicament_list.xml
@@ -17,7 +17,7 @@
-->
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_medicament_detail.xml b/app/src/main/res/layout/activity_medicament_detail.xml
index f772566..5123489 100644
--- a/app/src/main/res/layout/activity_medicament_detail.xml
+++ b/app/src/main/res/layout/activity_medicament_detail.xml
@@ -1,54 +1,57 @@
-
-
-
+ app:toolbarId="@+id/detail_toolbar" />
-
+
-
+
-
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
-
-
-
+
diff --git a/app/src/main/res/layout/activity_medicament_list.xml b/app/src/main/res/layout/activity_medicament_list.xml
index ac13e0c..34af492 100644
--- a/app/src/main/res/layout/activity_medicament_list.xml
+++ b/app/src/main/res/layout/activity_medicament_list.xml
@@ -1,5 +1,5 @@
-
-
-
-
+
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"/>
+
-
+ android:onClick="scanNow"
+ android:src="@drawable/ic_add_circle_black_24dp"
+ app:backgroundTint="@android:color/darker_gray"
+ app:fabCustomSize="60dp"
+ app:maxImageSize="60dp" />
-
+
+
+
diff --git a/app/src/main/res/layout/custom_barcode_scanner.xml b/app/src/main/res/layout/custom_barcode_scanner.xml
new file mode 100644
index 0000000..8870315
--- /dev/null
+++ b/app/src/main/res/layout/custom_barcode_scanner.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/custom_button.xml b/app/src/main/res/layout/custom_button.xml
index 8e7beed..ab48eb9 100644
--- a/app/src/main/res/layout/custom_button.xml
+++ b/app/src/main/res/layout/custom_button.xml
@@ -1,12 +1,13 @@
-
-
+ android:backgroundTint="@android:color/transparent"
+ app:fabCustomSize="60dp"
+ app:maxImageSize="60dp"
+ android:src="@drawable/ic_add_circle_black_24dp" />
diff --git a/app/src/main/res/layout/medicament_list.xml b/app/src/main/res/layout/medicament_list.xml
index cecc45c..645ee13 100644
--- a/app/src/main/res/layout/medicament_list.xml
+++ b/app/src/main/res/layout/medicament_list.xml
@@ -1,5 +1,5 @@
-
+ android:layout_marginStart="5dp" />
-
+ android:layout_marginRight="10sp"
+ android:contentDescription="@string/detail_view"
+ android:src="@drawable/ic_navigate_next_black_24dp" />
\ No newline at end of file
diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml
new file mode 100644
index 0000000..b5e2c82
--- /dev/null
+++ b/app/src/main/res/values-fr-rFR/strings.xml
@@ -0,0 +1,25 @@
+
+
+ PillDroid
+ Détail Médicament
+ Annuler
+ OK
+ Présentation
+ Nom
+ Mode d\'adminitration
+ Médicament introuvable dans la base de données
+ À propos
+ Aide
+ Prise
+ Seuil critique
+ Seuil d\'alerte
+ Médicament trouvé dans la base de données
+ Stock courant
+ Éteindre le flash
+ Allumer le flash
+ Vous devez passer à la pharmacie
+ Utilisez le clavier
+ Vue de détail
+ Scanner un code barre de médicament
+ Save
+
\ No newline at end of file
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..7ce840e
--- /dev/null
+++ b/app/src/main/res/values/attrs.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 079a0dc..54cdc3c 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -3,6 +3,8 @@
#3F51B5
#303F9F
#FF4081
+
+ #66000000
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c78e069..a27c3b9 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -3,9 +3,22 @@
Medicament Detail
Cancel
OK
- Médicament introuvable dans la base de données
- trouvé dans la base de données
- À propos
- Aide
- Vous devez passer à la pharmarcie -POUET
+ Drug not found in the database
+ Drug found in the database
+ About
+ Help
+ You have to go to the pharmacy
+ Turn Flash On
+ Turn Flash Off
+ Name
+ Presentation
+ Administration mode
+ Current stock
+ Take
+ Alert therehold
+ Critical threhold
+ "Use the keyboard"
+ Detail view
+ Scan a drug barcode
+ Save
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 04fa64e..49bfb37 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -16,4 +16,16 @@
+
+
+
+
diff --git a/build.gradle b/build.gradle
index 15163ff..871546c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -20,6 +20,10 @@ ext {
buildToolsVersion = '27.0.1'
var = '3.4.2'
buildToolsVersion1 = '29.0.3'
+ defaultMinSdkVersion = 28
+ defaultTargetSdkVersion = 28
+ defaultVersionCode = 1
+ defaultVersionCode1 = defaultVersionCode
}
allprojects {
diff --git a/gradle.properties b/gradle.properties
index 1d3591c..915f0e6 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# org.gradle.parallel=true
+android.enableJetifier=true
+android.useAndroidX=true
\ No newline at end of file