mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-13 00:51:35 +01:00
Merge branch 'feature/fix_scan' into develop
This commit is contained in:
commit
b5f7e17d34
33 changed files with 643 additions and 225 deletions
|
@ -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'
|
||||
}
|
||||
|
||||
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'
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -2,14 +2,21 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="net.foucry.pilldroid">
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:hardwareAccelerated="true"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@drawable/ic_launcher"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<!-- <activity
|
||||
android:name=".scanActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/title_activity_scan"
|
||||
android:theme="@style/FullscreenTheme"></activity>-->
|
||||
<activity
|
||||
android:name=".MedicamentListActivity"
|
||||
android:label="@string/app_name"
|
||||
|
@ -29,28 +36,35 @@
|
|||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="net.foucry.pilldroid.MedicamentListActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
<!-- <activity
|
||||
android:name="com.google.zxing.client.android.CaptureActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="com.google.zxing.client.android.SCAN"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<action android:name="com.google.zxing.client.android.SCAN" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".About"
|
||||
</activity>-->
|
||||
<activity
|
||||
android:name="About"
|
||||
android:label="À propos de PillDroid"
|
||||
android:parentActivityName=".MedicamentListActivity"
|
||||
android:theme="@style/AppTheme">
|
||||
</activity>
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity android:name=".CustomScannerActivity" />
|
||||
|
||||
<receiver android:name=".NotificationPublisher" />
|
||||
<service android:name=".PillDroidJobService"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE"/>
|
||||
|
||||
<service
|
||||
android:name=".PillDroidJobService"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Medicament> 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<Medicament>() {
|
||||
@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<Medicament>() {
|
||||
@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();
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
9
app/src/main/res/drawable/ic_add_circle_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_add_circle_black_24dp.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13h-4v4h-2v-4L7,13v-2h4L11,7h2v4h4v2z"/>
|
||||
</vector>
|
9
app/src/main/res/drawable/ic_cancel_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_cancel_black_24dp.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="85dp"
|
||||
android:height="85dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2zM17,15.59L15.59,17 12,13.41 8.41,17 7,15.59 10.59,12 7,8.41 8.41,7 12,10.59 15.59,7 17,8.41 13.41,12 17,15.59z"/>
|
||||
</vector>
|
4
app/src/main/res/drawable/ic_keyboard_black_24dp.xml
Normal file
4
app/src/main/res/drawable/ic_keyboard_black_24dp.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<vector android:height="100dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="100dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M20,5L4,5c-1.1,0 -1.99,0.9 -1.99,2L2,17c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2zM11,8h2v2h-2L11,8zM11,11h2v2h-2v-2zM8,8h2v2L8,10L8,8zM8,11h2v2L8,13v-2zM7,13L5,13v-2h2v2zM7,10L5,10L5,8h2v2zM16,17L8,17v-2h8v2zM16,13h-2v-2h2v2zM16,10h-2L14,8h2v2zM19,13h-2v-2h2v2zM19,10h-2L17,8h2v2z"/>
|
||||
</vector>
|
7
app/src/main/res/drawable/ic_reticule_rouge.xml
Normal file
7
app/src/main/res/drawable/ic_reticule_rouge.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<vector android:height="711dp" android:viewportHeight="297"
|
||||
android:viewportWidth="210" android:width="502.72726dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillAlpha="1" android:fillColor="#00000000"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="m80.391,100.944l-8.88,0c-5.942,0 -10.725,4.784 -10.725,10.725l0,4.83m77.258,0l0,-4.83c0,-5.942 -4.784,-10.725 -10.725,-10.725l-8.88,0M60.786,134.601l0,4.83c0,5.942 4.784,10.725 10.725,10.725l8.88,0m38.047,0l8.88,0c5.942,0 10.725,-4.784 10.725,-10.725l0,-4.83"
|
||||
android:strokeAlpha="1" android:strokeColor="#ff0000" android:strokeWidth="5.6692915"/>
|
||||
</vector>
|
7
app/src/main/res/drawable/ic_reticule_vert.xml
Normal file
7
app/src/main/res/drawable/ic_reticule_vert.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<vector android:height="725.52856dp" android:viewportHeight="297"
|
||||
android:viewportWidth="210" android:width="513dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillAlpha="1" android:fillColor="#00000000"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="m80.391,100.944l-8.88,0c-5.942,0 -10.725,4.784 -10.725,10.725l0,4.83m77.258,0l0,-4.83c0,-5.942 -4.784,-10.725 -10.725,-10.725l-8.88,0M60.786,134.601l0,4.83c0,5.942 4.784,10.725 10.725,10.725l8.88,0m38.047,0l8.88,0c5.942,0 10.725,-4.784 10.725,-10.725l0,-4.83"
|
||||
android:strokeAlpha="1" android:strokeColor="#00ff00" android:strokeWidth="5.6692915"/>
|
||||
</vector>
|
|
@ -1,9 +1,4 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
|
||||
<vector android:height="60dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="60dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
|
||||
</vector>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
-->
|
||||
|
||||
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/medicament_list"
|
||||
android:name="net.foucry.pilldroid.MedicamentListFragment"
|
||||
|
|
25
app/src/main/res/layout/activity_custom_scanner.xml
Normal file
25
app/src/main/res/layout/activity_custom_scanner.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="example.zxing.CustomScannerActivity">
|
||||
|
||||
<com.journeyapps.barcodescanner.DecoratedBarcodeView
|
||||
android:id="@+id/zxing_barcode_scanner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:zxing_scanner_layout="@layout/custom_barcode_scanner">
|
||||
</com.journeyapps.barcodescanner.DecoratedBarcodeView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/switch_flashlight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/turn_on_flashlight"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:onClick="switchFlashlight"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,54 +1,57 @@
|
|||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:background="@drawable/list_selector"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="net.foucry.pilldroid.MedicamentDetailActivity"
|
||||
tools:ignore="MergeRootFrame">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/app_bar_height"
|
||||
android:fitsSystemWindows="true"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:fitsSystemWindows="true"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
app:toolbarId="@+id/detail_toolbar"/>
|
||||
app:toolbarId="@+id/detail_toolbar" />
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/detail_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/detail_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/medicament_detail_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
<ImageButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:contentDescription="@string/save_button"
|
||||
android:src="@drawable/ic_save_black_24dp"
|
||||
app:backgroundTint="@android:color/transparent"
|
||||
app:layout_anchor="@+id/medicament_detail_container"
|
||||
app:layout_anchorGravity="top|end" />
|
||||
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -7,19 +7,19 @@
|
|||
android:fitsSystemWindows="true"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/app_bar_height"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/frameLayout"
|
||||
|
@ -29,20 +29,29 @@
|
|||
|
||||
<include
|
||||
layout="@layout/medicament_list"
|
||||
android:layout_height="598dp" />
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:onClick="scanNow"
|
||||
android:src="@android:drawable/ic_input_add"
|
||||
android:accessibilityHeading="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:baselineAlignBottom="false"
|
||||
android:clickable="false"
|
||||
android:baselineAlignBottom="false"/>
|
||||
android:onClick="scanNow"
|
||||
android:src="@drawable/ic_add_circle_black_24dp"
|
||||
app:backgroundTint="@android:color/darker_gray"
|
||||
app:fabCustomSize="60dp"
|
||||
app:maxImageSize="60dp" />
|
||||
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
62
app/src/main/res/layout/custom_barcode_scanner.xml
Normal file
62
app/src/main/res/layout/custom_barcode_scanner.xml
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.journeyapps.barcodescanner.BarcodeView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/zxing_barcode_surface"
|
||||
app:zxing_framing_rect_width="250dp"
|
||||
app:zxing_framing_rect_height="50dp">
|
||||
</com.journeyapps.barcodescanner.BarcodeView>
|
||||
|
||||
<com.journeyapps.barcodescanner.ViewfinderView
|
||||
android:id="@+id/zxing_viewfinder_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
app:zxing_possible_result_points="@color/zxing_custom_possible_result_points"
|
||||
app:zxing_result_view="@color/zxing_custom_result_view"
|
||||
app:zxing_viewfinder_laser="@color/zxing_custom_viewfinder_laser"
|
||||
app:zxing_viewfinder_laser_visibility="true"
|
||||
app:zxing_viewfinder_mask="@color/zxing_custom_viewfinder_mask" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/zxing_status_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal|top"
|
||||
android:background="@color/zxing_transparent"
|
||||
android:fontFamily="sans-serif-black"
|
||||
android:text="@string/zxing_msg_default_status"
|
||||
android:textColor="@color/design_default_color_primary_dark"
|
||||
tools:ignore="PrivateResource" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/cancel_button"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_gravity="bottom|start"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:accessibilityHeading="true"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:clickable="false"
|
||||
android:contentDescription="@string/button_cancel"
|
||||
android:cropToPadding="false"
|
||||
android:foregroundTint="@android:color/darker_gray"
|
||||
android:onClick="onCancel"
|
||||
android:src="@drawable/ic_cancel_black_24dp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/keyboard_button"
|
||||
android:layout_width="86dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:contentDescription="@string/button_keyboard"
|
||||
android:onClick="onKeyboard"
|
||||
android:src="@drawable/ic_keyboard_black_24dp" />
|
||||
|
||||
</merge>
|
|
@ -1,12 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.FloatingActionButton xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/fb"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="top|center"
|
||||
android:backgroundTint="@drawable/fb_play_bg"
|
||||
android:src="@drawable/fb_icon_play" />
|
||||
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
app:fabCustomSize="60dp"
|
||||
app:maxImageSize="60dp"
|
||||
android:src="@drawable/ic_add_circle_black_24dp" />
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/medicament_list"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
android:id="@+id/list_image"
|
||||
android:layout_width="50sp"
|
||||
android:layout_height="50sp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:src="@drawable/ok_stock"
|
||||
android:contentDescription="Icone de stock"
|
||||
android:layout_centerVertical="true"
|
||||
|
@ -41,7 +41,7 @@
|
|||
android:text="cip13 goes here"
|
||||
android:layout_below="@+id/valeur"
|
||||
android:layout_toEndOf="@+id/list_image"
|
||||
android:layout_marginLeft="5dp" />
|
||||
android:layout_marginStart="5dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/endOfStock"
|
||||
|
@ -49,7 +49,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:text="lundi 1 janvier 2001"
|
||||
android:layout_marginRight="15dp"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#212121"
|
||||
android:textStyle="bold"
|
||||
|
@ -64,11 +63,13 @@
|
|||
<!-- dateEndOfStock -->
|
||||
|
||||
<!-- Rightend Arrow -->
|
||||
<ImageView android:layout_width="wrap_content"
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_navigate_next_black_24dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="10sp"/>
|
||||
android:layout_marginRight="10sp"
|
||||
android:contentDescription="@string/detail_view"
|
||||
android:src="@drawable/ic_navigate_next_black_24dp" />
|
||||
|
||||
</RelativeLayout>
|
25
app/src/main/res/values-fr-rFR/strings.xml
Normal file
25
app/src/main/res/values-fr-rFR/strings.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">PillDroid</string>
|
||||
<string name="title_medicament_detail">Détail Médicament</string>
|
||||
<string name="button_cancel">Annuler</string>
|
||||
<string name="button_ok">OK</string>
|
||||
<string name="med_presention_labal">Présentation</string>
|
||||
<string name="med_name_label">Nom</string>
|
||||
<string name="med_administationMode_label">Mode d\'adminitration</string>
|
||||
<string name="msgNotFound">Médicament introuvable dans la base de données</string>
|
||||
<string name="about">À propos</string>
|
||||
<string name="help">Aide</string>
|
||||
<string name="med_take_label">Prise</string>
|
||||
<string name="med_criticalTherehold_label">Seuil critique</string>
|
||||
<string name="med_warningTherehold_label">Seuil d\'alerte</string>
|
||||
<string name="msgFound">Médicament trouvé dans la base de données</string>
|
||||
<string name="med_current_stock_label">Stock courant</string>
|
||||
<string name="turn_off_flashlight">Éteindre le flash</string>
|
||||
<string name="turn_on_flashlight">Allumer le flash</string>
|
||||
<string name="notification_text">Vous devez passer à la pharmacie</string>
|
||||
<string name="button_keyboard">Utilisez le clavier</string>
|
||||
<string name="detail_view">Vue de détail</string>
|
||||
<string name="scan_action">Scanner un code barre de médicament</string>
|
||||
<string name="save_button">Save</string>
|
||||
</resources>
|
12
app/src/main/res/values/attrs.xml
Normal file
12
app/src/main/res/values/attrs.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<resources>
|
||||
|
||||
<!-- Declare custom theme attributes that allow changing which styles are
|
||||
used for button bars depending on the API level.
|
||||
?android:attr/buttonBarStyle is new as of API 11 so this is
|
||||
necessary to support previous API levels. -->
|
||||
<declare-styleable name="ButtonBarContainerTheme">
|
||||
<attr name="metaButtonBarStyle" format="reference" />
|
||||
<attr name="metaButtonBarButtonStyle" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
|
@ -3,6 +3,8 @@
|
|||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
|
||||
<color name="black_overlay">#66000000</color>
|
||||
<!-- Android standard ICS color -->
|
||||
<!-- Android standard ICS color -->
|
||||
<!-- Android standard ICS color -->
|
||||
|
|
|
@ -3,9 +3,22 @@
|
|||
<string name="title_medicament_detail">Medicament Detail</string>
|
||||
<string name="button_cancel">Cancel</string>
|
||||
<string name="button_ok">OK</string>
|
||||
<string name="msgNotFound">Médicament introuvable dans la base de données</string>
|
||||
<string name="msgFound">trouvé dans la base de données</string>
|
||||
<string name="about">À propos</string>
|
||||
<string name="help">Aide</string>
|
||||
<string name="notification_text">Vous devez passer à la pharmarcie -POUET</string>
|
||||
<string name="msgNotFound">Drug not found in the database</string>
|
||||
<string name="msgFound">Drug found in the database</string>
|
||||
<string name="about">About</string>
|
||||
<string name="help">Help</string>
|
||||
<string name="notification_text">You have to go to the pharmacy</string>
|
||||
<string name="turn_on_flashlight">Turn Flash On</string>
|
||||
<string name="turn_off_flashlight">Turn Flash Off</string>
|
||||
<string name="med_name_label">Name</string>
|
||||
<string name="med_presention_labal">Presentation</string>
|
||||
<string name="med_administationMode_label">Administration mode</string>
|
||||
<string name="med_current_stock_label">Current stock</string>
|
||||
<string name="med_take_label">Take</string>
|
||||
<string name="med_warningTherehold_label">Alert therehold</string>
|
||||
<string name="med_criticalTherehold_label">Critical threhold</string>
|
||||
<string name="button_keyboard">"Use the keyboard"</string>
|
||||
<string name="detail_view">Detail view</string>
|
||||
<string name="scan_action">Scan a drug barcode</string>
|
||||
<string name="save_button">Save</string>
|
||||
</resources>
|
||||
|
|
|
@ -16,4 +16,16 @@
|
|||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
<style name="FullscreenTheme" parent="AppTheme">
|
||||
<item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:windowBackground">@null</item>
|
||||
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
|
||||
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
|
||||
</style>
|
||||
|
||||
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
|
||||
<item name="android:background">@color/black_overlay</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
# org.gradle.parallel=true
|
||||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
Loading…
Reference in a new issue