mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
As suggested by @Jean-BaptisteC, reformatting code with Android Studio
This commit is contained in:
parent
feb95329be
commit
9bb5e62c48
33 changed files with 561 additions and 569 deletions
|
@ -2,15 +2,14 @@ package net.foucry.pilldroid;
|
||||||
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import android.webkit.WebView;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by jacques on 12/06/16.
|
* Created by jacques on 12/06/16.
|
||||||
*/
|
*/
|
||||||
public class About extends AppCompatActivity{
|
public class About extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
|
@ -31,103 +31,6 @@ public class AlarmReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
NotificationManager notificationManager;
|
NotificationManager notificationManager;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent)
|
|
||||||
{
|
|
||||||
// Show the toast like in above screen shot
|
|
||||||
Log.d(TAG, "onReceive");
|
|
||||||
|
|
||||||
// If BOOT_COMPLETED is received we launch an alarm in 10 second in order to
|
|
||||||
// start the alarmschedule process.
|
|
||||||
|
|
||||||
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
|
||||||
Log.d(TAG, "StartUpBootReceiver BOOT_COMPLETED");
|
|
||||||
scheduleAlarm(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) { Toast.makeText(context, "New stock calculated", Toast.LENGTH_LONG).show(); }
|
|
||||||
createNotificationChannel(context);
|
|
||||||
PrescriptionDatabase prescriptions = PrescriptionDatabase.getInstanceDatabase(context.getApplicationContext());
|
|
||||||
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
|
|
||||||
List<Prescription> prescriptionList = prescriptionsDAO.getAllMedics();
|
|
||||||
Prescription firstPrescription = null;
|
|
||||||
Prescription currentPrescription;
|
|
||||||
|
|
||||||
for (int i=0 ; i < prescriptionList.size(); i++ ) {
|
|
||||||
currentPrescription = prescriptionList.get(i);
|
|
||||||
currentPrescription.newStock();
|
|
||||||
prescriptionsDAO.update(currentPrescription);
|
|
||||||
}
|
|
||||||
// Sorting list by dateEndOfStock
|
|
||||||
prescriptionList = prescriptionsDAO.getAllMedics(); // Reread the database
|
|
||||||
Utils.sortPrescriptionList(prescriptionList);
|
|
||||||
try {
|
|
||||||
firstPrescription = prescriptionList.get(0);
|
|
||||||
}
|
|
||||||
catch (Exception e){
|
|
||||||
Log.e(TAG, e.toString());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (firstPrescription != null) {
|
|
||||||
if (firstPrescription.getTake() != 0) {
|
|
||||||
if(firstPrescription.getStock() <= firstPrescription.getAlertThreshold()) {
|
|
||||||
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
|
|
||||||
Intent notificationIntent = new Intent(context, DrugListActivity.class);
|
|
||||||
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
|
|
||||||
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
||||||
|
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
|
|
||||||
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "PillDroid")
|
|
||||||
.setSmallIcon(R.drawable.ic_pill_alarm)
|
|
||||||
.setContentTitle(context.getString(R.string.app_name))
|
|
||||||
.setContentText(context.getString(R.string.notification_text))
|
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
|
||||||
.setContentIntent(pendingIntent)
|
|
||||||
.setColorized(true)
|
|
||||||
.setAutoCancel(true);
|
|
||||||
|
|
||||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
|
||||||
int notificationId = 666;
|
|
||||||
notificationManager.notify(notificationId, builder.build());
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
double dummy = (firstPrescription.getStock() - firstPrescription.getAlertThreshold());
|
|
||||||
Log.d(TAG, "no notification scheduled " + dummy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createNotificationChannel(Context context) {
|
|
||||||
|
|
||||||
Log.d(TAG, "start create notification channel");
|
|
||||||
CharSequence name = context.getString(R.string.channel_name);
|
|
||||||
String description = context.getString(R.string.channel_description);
|
|
||||||
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
|
||||||
String CHANNEL_ID = "PillDroid";
|
|
||||||
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
|
|
||||||
channel.setDescription(description);
|
|
||||||
channel.enableLights(true);
|
|
||||||
channel.setLightColor(R.color.led);
|
|
||||||
channel.enableVibration(true);
|
|
||||||
channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
|
|
||||||
// Register the channel with the system; you can't change the importance
|
|
||||||
// or other notification behaviors after this
|
|
||||||
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
|
|
||||||
try {
|
|
||||||
notificationManager.createNotificationChannel(channel);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// This will catch any exception, because they are all descended from Exception
|
|
||||||
Log.e(TAG, e.toString());
|
|
||||||
//At the level Exception Class handle the error in Exception Table
|
|
||||||
// Exception Create That Error Object and throw it
|
|
||||||
//E.g: FileNotFoundException ,etc
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static void scheduleAlarm(Context context) {
|
public static void scheduleAlarm(Context context) {
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
Date today;
|
Date today;
|
||||||
|
@ -166,11 +69,110 @@ public class AlarmReceiver extends BroadcastReceiver {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
Log.d(TAG, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()));
|
Log.d(TAG, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()));
|
||||||
if (BuildConfig.DEBUG) { Toast.makeText(context, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()), Toast.LENGTH_SHORT).show(); }
|
if (BuildConfig.DEBUG) {
|
||||||
|
Toast.makeText(context, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean isAlarmScheduled(Context context) {
|
public static Boolean isAlarmScheduled(Context context) {
|
||||||
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
return alarmManager.getNextAlarmClock() != null;
|
return alarmManager.getNextAlarmClock() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
// Show the toast like in above screen shot
|
||||||
|
Log.d(TAG, "onReceive");
|
||||||
|
|
||||||
|
// If BOOT_COMPLETED is received we launch an alarm in 10 second in order to
|
||||||
|
// start the alarmschedule process.
|
||||||
|
|
||||||
|
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||||
|
Log.d(TAG, "StartUpBootReceiver BOOT_COMPLETED");
|
||||||
|
scheduleAlarm(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
Toast.makeText(context, "New stock calculated", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
createNotificationChannel(context);
|
||||||
|
PrescriptionDatabase prescriptions = PrescriptionDatabase.getInstanceDatabase(context.getApplicationContext());
|
||||||
|
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
|
||||||
|
List<Prescription> prescriptionList = prescriptionsDAO.getAllMedics();
|
||||||
|
Prescription firstPrescription = null;
|
||||||
|
Prescription currentPrescription;
|
||||||
|
|
||||||
|
for (int i = 0; i < prescriptionList.size(); i++) {
|
||||||
|
currentPrescription = prescriptionList.get(i);
|
||||||
|
currentPrescription.newStock();
|
||||||
|
prescriptionsDAO.update(currentPrescription);
|
||||||
|
}
|
||||||
|
// Sorting list by dateEndOfStock
|
||||||
|
prescriptionList = prescriptionsDAO.getAllMedics(); // Reread the database
|
||||||
|
Utils.sortPrescriptionList(prescriptionList);
|
||||||
|
try {
|
||||||
|
firstPrescription = prescriptionList.get(0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstPrescription != null) {
|
||||||
|
if (firstPrescription.getTake() != 0) {
|
||||||
|
if (firstPrescription.getStock() <= firstPrescription.getAlertThreshold()) {
|
||||||
|
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
Intent notificationIntent = new Intent(context, DrugListActivity.class);
|
||||||
|
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
|
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
|
||||||
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
|
||||||
|
|
||||||
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "PillDroid")
|
||||||
|
.setSmallIcon(R.drawable.ic_pill_alarm)
|
||||||
|
.setContentTitle(context.getString(R.string.app_name))
|
||||||
|
.setContentText(context.getString(R.string.notification_text))
|
||||||
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
|
.setContentIntent(pendingIntent)
|
||||||
|
.setColorized(true)
|
||||||
|
.setAutoCancel(true);
|
||||||
|
|
||||||
|
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||||
|
int notificationId = 666;
|
||||||
|
notificationManager.notify(notificationId, builder.build());
|
||||||
|
} else {
|
||||||
|
double dummy = (firstPrescription.getStock() - firstPrescription.getAlertThreshold());
|
||||||
|
Log.d(TAG, "no notification scheduled " + dummy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createNotificationChannel(Context context) {
|
||||||
|
|
||||||
|
Log.d(TAG, "start create notification channel");
|
||||||
|
CharSequence name = context.getString(R.string.channel_name);
|
||||||
|
String description = context.getString(R.string.channel_description);
|
||||||
|
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
||||||
|
String CHANNEL_ID = "PillDroid";
|
||||||
|
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
|
||||||
|
channel.setDescription(description);
|
||||||
|
channel.enableLights(true);
|
||||||
|
channel.setLightColor(R.color.led);
|
||||||
|
channel.enableVibration(true);
|
||||||
|
channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
|
||||||
|
// Register the channel with the system; you can't change the importance
|
||||||
|
// or other notification behaviors after this
|
||||||
|
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
|
||||||
|
try {
|
||||||
|
notificationManager.createNotificationChannel(channel);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// This will catch any exception, because they are all descended from Exception
|
||||||
|
Log.e(TAG, e.toString());
|
||||||
|
//At the level Exception Class handle the error in Exception Table
|
||||||
|
// Exception Create That Error Object and throw it
|
||||||
|
//E.g: FileNotFoundException ,etc
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,12 @@ import com.journeyapps.barcodescanner.ViewfinderView;
|
||||||
public class CustomScannerActivity extends Activity implements DecoratedBarcodeView.TorchListener {
|
public class CustomScannerActivity extends Activity implements DecoratedBarcodeView.TorchListener {
|
||||||
|
|
||||||
private static final String TAG = CustomScannerActivity.class.getName();
|
private static final String TAG = CustomScannerActivity.class.getName();
|
||||||
|
final Bundle captureIntentBundle = new Bundle();
|
||||||
private CaptureManager capture;
|
private CaptureManager capture;
|
||||||
private DecoratedBarcodeView barcodeScannerView;
|
private DecoratedBarcodeView barcodeScannerView;
|
||||||
private ImageButton switchFlashlightButton;
|
private ImageButton switchFlashlightButton;
|
||||||
private ViewfinderView viewfinderView;
|
private ViewfinderView viewfinderView;
|
||||||
|
|
||||||
final Bundle captureIntentBundle = new Bundle();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -147,7 +145,7 @@ public class CustomScannerActivity extends Activity implements DecoratedBarcodeV
|
||||||
public void onKeyboard(View view) {
|
public void onKeyboard(View view) {
|
||||||
Log.d(TAG, "onkeyboard");
|
Log.d(TAG, "onkeyboard");
|
||||||
Intent resultIntent = new Intent();
|
Intent resultIntent = new Intent();
|
||||||
resultIntent.putExtra("returnCode",3);
|
resultIntent.putExtra("returnCode", 3);
|
||||||
CustomScannerActivity.this.setResult(RESULT_OK, resultIntent);
|
CustomScannerActivity.this.setResult(RESULT_OK, resultIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,6 @@ class DBDrugs extends SQLiteOpenHelper {
|
||||||
private static final int DATABASE_VERSION = 1;
|
private static final int DATABASE_VERSION = 1;
|
||||||
|
|
||||||
private static final String dbName = "drugs.db";
|
private static final String dbName = "drugs.db";
|
||||||
private final Context myContext;
|
|
||||||
private final SQLiteDatabase myDataBase = null;
|
|
||||||
|
|
||||||
private static final String TABLE_NAME = "drugs";
|
private static final String TABLE_NAME = "drugs";
|
||||||
private static final String DRUG_CIS = "cis";
|
private static final String DRUG_CIS = "cis";
|
||||||
private static final String DRUG_CIP13 = "cip13";
|
private static final String DRUG_CIP13 = "cip13";
|
||||||
|
@ -32,11 +29,10 @@ class DBDrugs extends SQLiteOpenHelper {
|
||||||
private static final String DRUG_ADMIN = "administration_mode";
|
private static final String DRUG_ADMIN = "administration_mode";
|
||||||
private static final String DRUG_NAME = "name";
|
private static final String DRUG_NAME = "name";
|
||||||
private static final String DRUG_PRES = "presentation";
|
private static final String DRUG_PRES = "presentation";
|
||||||
|
|
||||||
private static final String[] COLUMNS_NAMES = {DRUG_CIS, DRUG_CIP13, DRUG_CIP7, DRUG_ADMIN, DRUG_NAME, DRUG_PRES};
|
private static final String[] COLUMNS_NAMES = {DRUG_CIS, DRUG_CIP13, DRUG_CIP7, DRUG_ADMIN, DRUG_NAME, DRUG_PRES};
|
||||||
|
|
||||||
private static final String TAG = DBDrugs.class.getName();
|
private static final String TAG = DBDrugs.class.getName();
|
||||||
|
private final Context myContext;
|
||||||
|
private final SQLiteDatabase myDataBase = null;
|
||||||
|
|
||||||
|
|
||||||
DBDrugs(Context context) {
|
DBDrugs(Context context) {
|
||||||
|
@ -44,12 +40,10 @@ class DBDrugs extends SQLiteOpenHelper {
|
||||||
this.myContext = context;
|
this.myContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDBFileExist(File database)
|
public boolean isDBFileExist(File database) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
myContext.getDatabasePath(String.valueOf(database));
|
myContext.getDatabasePath(String.valueOf(database));
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (final Exception e){
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -169,19 +163,17 @@ class DBDrugs extends SQLiteOpenHelper {
|
||||||
String cip13 = null;
|
String cip13 = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Cursor c = this.getReadableDatabase().rawQuery("SELECT cip13 FROM "+ TABLE_NAME + " where cip7 = "+cip7, null);
|
Cursor c = this.getReadableDatabase().rawQuery("SELECT cip13 FROM " + TABLE_NAME + " where cip7 = " + cip7, null);
|
||||||
|
|
||||||
Log.d(TAG, "Cursor == " + DatabaseUtils.dumpCursorToString(c));
|
Log.d(TAG, "Cursor == " + DatabaseUtils.dumpCursorToString(c));
|
||||||
|
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
|
|
||||||
if(c.getCount()>0)
|
if (c.getCount() > 0) {
|
||||||
{
|
|
||||||
cip13 = c.getString(0);
|
cip13 = c.getString(0);
|
||||||
}
|
}
|
||||||
c.close();
|
c.close();
|
||||||
} catch(Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return cip13;
|
return cip13;
|
||||||
|
|
|
@ -18,7 +18,6 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DBHelper extends SQLiteOpenHelper {
|
class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 1;
|
private static final int DATABASE_VERSION = 1;
|
||||||
|
@ -36,13 +35,10 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
private static final String KEY_THRESHOLD_WARN = "warning";
|
private static final String KEY_THRESHOLD_WARN = "warning";
|
||||||
private static final String KEY_THRESHOLD_ALERT = "alert";
|
private static final String KEY_THRESHOLD_ALERT = "alert";
|
||||||
private static final String KEY_LAST_UPDATE = "last_update";
|
private static final String KEY_LAST_UPDATE = "last_update";
|
||||||
|
|
||||||
final List<Drug> drugs = new ArrayList<>();
|
|
||||||
|
|
||||||
private static final String TAG = DBHelper.class.getName();
|
private static final String TAG = DBHelper.class.getName();
|
||||||
|
private static final String[] COLUMNS = {KEY_ID, KEY_CIS, KEY_CIP13, KEY_NAME, KEY_ADMIN, KEY_PRES, KEY_STOCK, KEY_TAKE,
|
||||||
private static final String[] COLUMNS = {KEY_ID, KEY_CIS,KEY_CIP13, KEY_NAME, KEY_ADMIN, KEY_PRES, KEY_STOCK, KEY_TAKE,
|
|
||||||
KEY_THRESHOLD_WARN, KEY_THRESHOLD_ALERT, KEY_LAST_UPDATE};
|
KEY_THRESHOLD_WARN, KEY_THRESHOLD_ALERT, KEY_LAST_UPDATE};
|
||||||
|
final List<Drug> drugs = new ArrayList<>();
|
||||||
|
|
||||||
DBHelper(Context context) {
|
DBHelper(Context context) {
|
||||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
|
@ -88,6 +84,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Split drug values into database record and record it to the DB
|
* Split drug values into database record and record it to the DB
|
||||||
|
*
|
||||||
* @param drug the drug object to be saved
|
* @param drug the drug object to be saved
|
||||||
*/
|
*/
|
||||||
void addDrug(Drug drug) {
|
void addDrug(Drug drug) {
|
||||||
|
@ -123,6 +120,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return a drug from the DB with is id
|
* return a drug from the DB with is id
|
||||||
|
*
|
||||||
* @param id of the drug we looking for (not used)
|
* @param id of the drug we looking for (not used)
|
||||||
* @return return the found drug of null
|
* @return return the found drug of null
|
||||||
*/
|
*/
|
||||||
|
@ -134,7 +132,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
Cursor cursor = db.query(TABLE_DRUG, // Which table
|
Cursor cursor = db.query(TABLE_DRUG, // Which table
|
||||||
COLUMNS, // column names
|
COLUMNS, // column names
|
||||||
" id = ?", // selections
|
" id = ?", // selections
|
||||||
new String[] { String.valueOf(id) }, // selections args
|
new String[]{String.valueOf(id)}, // selections args
|
||||||
null, // group by
|
null, // group by
|
||||||
null, // having
|
null, // having
|
||||||
null, // order by
|
null, // order by
|
||||||
|
@ -161,7 +159,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
drug.setDateLastUpdate(Long.parseLong(cursor.getString(10)));
|
drug.setDateLastUpdate(Long.parseLong(cursor.getString(10)));
|
||||||
}
|
}
|
||||||
// Log
|
// Log
|
||||||
Log.d(TAG, "getDrug("+id+")" + drug);
|
Log.d(TAG, "getDrug(" + id + ")" + drug);
|
||||||
|
|
||||||
assert cursor != null;
|
assert cursor != null;
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@ -172,7 +170,6 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param cip13 drug id in French nomenclature
|
* @param cip13 drug id in French nomenclature
|
||||||
* @return the drug object found in DB or null
|
* @return the drug object found in DB or null
|
||||||
*/
|
*/
|
||||||
|
@ -218,7 +215,6 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return a Sorted and updated by dateEndOfStock List of All drugs presents in database
|
* @return a Sorted and updated by dateEndOfStock List of All drugs presents in database
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -262,18 +258,16 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
Drug currentDrug;
|
Drug currentDrug;
|
||||||
for (int position = 0 ; position < getCount() ; position++ ) {
|
for (int position = 0; position < getCount(); position++) {
|
||||||
currentDrug = getItem(position);
|
currentDrug = getItem(position);
|
||||||
|
|
||||||
if (!DateUtils.isToday(currentDrug.getDateLastUpdate()))
|
if (!DateUtils.isToday(currentDrug.getDateLastUpdate())) {
|
||||||
{
|
|
||||||
currentDrug.newStock();
|
currentDrug.newStock();
|
||||||
updateDrug(currentDrug);
|
updateDrug(currentDrug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Log.d(TAG, "Before sort == " + drugs);
|
Log.d(TAG, "Before sort == " + drugs);
|
||||||
|
|
||||||
drugs.sort(new Comparator<Drug>() {
|
drugs.sort(new Comparator<Drug>() {
|
||||||
|
@ -289,16 +283,14 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
// Move drug with prise = 0 at the end of the list
|
// Move drug with prise = 0 at the end of the list
|
||||||
// todo: If some drug moved, must redo all the loop
|
// todo: If some drug moved, must redo all the loop
|
||||||
int position = 0 ;
|
int position = 0;
|
||||||
for ( int nbOps = 0; nbOps < getCount() ; nbOps ++ ) {
|
for (int nbOps = 0; nbOps < getCount(); nbOps++) {
|
||||||
currentDrug = getItem(position);
|
currentDrug = getItem(position);
|
||||||
double currentTake = currentDrug.getTake();
|
double currentTake = currentDrug.getTake();
|
||||||
if (currentTake == 0)
|
if (currentTake == 0) {
|
||||||
{
|
|
||||||
drug = drugs.remove(position);
|
drug = drugs.remove(position);
|
||||||
drugs.add(drug);
|
drugs.add(drug);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
position++;
|
position++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,7 +298,6 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param drug object to be updated in DB
|
* @param drug object to be updated in DB
|
||||||
*/
|
*/
|
||||||
public void updateDrug(Drug drug) {
|
public void updateDrug(Drug drug) {
|
||||||
|
@ -331,7 +322,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
values.put(KEY_THRESHOLD_ALERT, drug.getAlertThreshold());
|
values.put(KEY_THRESHOLD_ALERT, drug.getAlertThreshold());
|
||||||
values.put(KEY_LAST_UPDATE, drug.getDateLastUpdate());
|
values.put(KEY_LAST_UPDATE, drug.getDateLastUpdate());
|
||||||
|
|
||||||
String[] selectionArgs = { String.valueOf(drug.getId()) };
|
String[] selectionArgs = {String.valueOf(drug.getId())};
|
||||||
|
|
||||||
db.update(TABLE_DRUG, // table
|
db.update(TABLE_DRUG, // table
|
||||||
values, // column/value
|
values, // column/value
|
||||||
|
@ -345,6 +336,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a drug object in database
|
* Delete a drug object in database
|
||||||
|
*
|
||||||
* @param drug object to be delete in the DB
|
* @param drug object to be delete in the DB
|
||||||
*/
|
*/
|
||||||
public void deleteDrug(Drug drug) {
|
public void deleteDrug(Drug drug) {
|
||||||
|
@ -353,18 +345,19 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
// Delete record
|
// Delete record
|
||||||
db.delete(TABLE_DRUG, // table
|
db.delete(TABLE_DRUG, // table
|
||||||
KEY_ID+ " = ?", // selections
|
KEY_ID + " = ?", // selections
|
||||||
new String[] { String.valueOf(drug.getId()) } ); // selections args
|
new String[]{String.valueOf(drug.getId())}); // selections args
|
||||||
|
|
||||||
// Close DB
|
// Close DB
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
// log
|
// log
|
||||||
Log.d(TAG, "delete drug "+ drug);
|
Log.d(TAG, "delete drug " + drug);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get count of all drug present in database
|
* Get count of all drug present in database
|
||||||
|
*
|
||||||
* @return number of drug in DB
|
* @return number of drug in DB
|
||||||
*/
|
*/
|
||||||
int getCount() {
|
int getCount() {
|
||||||
|
@ -389,15 +382,13 @@ class DBHelper extends SQLiteOpenHelper {
|
||||||
boolean isDrugExist(String cip13) {
|
boolean isDrugExist(String cip13) {
|
||||||
boolean value = false;
|
boolean value = false;
|
||||||
try {
|
try {
|
||||||
Cursor c = this.getReadableDatabase().rawQuery("SELECT * FROM "+ TABLE_DRUG + " where cip13 = "+cip13, null);
|
Cursor c = this.getReadableDatabase().rawQuery("SELECT * FROM " + TABLE_DRUG + " where cip13 = " + cip13, null);
|
||||||
|
|
||||||
if(c.getCount()>0)
|
if (c.getCount() > 0) {
|
||||||
{
|
|
||||||
value = true;
|
value = true;
|
||||||
}
|
}
|
||||||
c.close();
|
c.close();
|
||||||
} catch(Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package net.foucry.pilldroid;
|
package net.foucry.pilldroid;
|
||||||
|
|
||||||
|
import static net.foucry.pilldroid.UtilDate.dateAtNoon;
|
||||||
|
import static net.foucry.pilldroid.UtilDate.nbOfDaysBetweenDateAndToday;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -7,9 +10,6 @@ import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static net.foucry.pilldroid.UtilDate.dateAtNoon;
|
|
||||||
import static net.foucry.pilldroid.UtilDate.nbOfDaysBetweenDateAndToday;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by jacques on 26/11/15.
|
* Created by jacques on 26/11/15.
|
||||||
*/
|
*/
|
||||||
|
@ -56,86 +56,68 @@ public class Drug implements Serializable {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getCip13() {
|
|
||||||
return cip13;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getCis() {
|
|
||||||
return cis;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getAdministration_mode() {
|
|
||||||
return administration_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getPresentation() {
|
|
||||||
return presentation;
|
|
||||||
}
|
|
||||||
|
|
||||||
double getStock() {
|
|
||||||
return stock;
|
|
||||||
}
|
|
||||||
|
|
||||||
double getTake() {
|
|
||||||
return take;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getAlertThreshold() {
|
|
||||||
return alertThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getWarnThreshold() {
|
|
||||||
return warnThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
long getDateLastUpdate() {
|
|
||||||
return dateLastUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
Date getDateEndOfStock() {
|
|
||||||
return dateEndOfStock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
public void setId(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
void setName(String name) {
|
void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getCip13() {
|
||||||
|
return cip13;
|
||||||
|
}
|
||||||
|
|
||||||
void setCip13(String cip13) {
|
void setCip13(String cip13) {
|
||||||
this.cip13 = cip13;
|
this.cip13 = cip13;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getCis() {
|
||||||
|
return cis;
|
||||||
|
}
|
||||||
|
|
||||||
void setCis(String cis) {
|
void setCis(String cis) {
|
||||||
this.cis = cis;
|
this.cis = cis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getAdministration_mode() {
|
||||||
|
return administration_mode;
|
||||||
|
}
|
||||||
|
|
||||||
void setAdministration_mode(String administration_mode) {
|
void setAdministration_mode(String administration_mode) {
|
||||||
this.administration_mode = administration_mode;
|
this.administration_mode = administration_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getPresentation() {
|
||||||
|
return presentation;
|
||||||
|
}
|
||||||
|
|
||||||
void setPresentation(String presentation) {
|
void setPresentation(String presentation) {
|
||||||
this.presentation = presentation;
|
this.presentation = presentation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double getStock() {
|
||||||
|
return stock;
|
||||||
|
}
|
||||||
|
|
||||||
void setStock(double stock) {
|
void setStock(double stock) {
|
||||||
this.stock = stock;
|
this.stock = stock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double getTake() {
|
||||||
|
return take;
|
||||||
|
}
|
||||||
|
|
||||||
void setTake(double take) {
|
void setTake(double take) {
|
||||||
this.take = take;
|
this.take = take;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWarnThreshold(int warn) {
|
int getAlertThreshold() {
|
||||||
if (warn == 0)
|
return alertThreshold;
|
||||||
warn = 14;
|
|
||||||
this.warnThreshold = warn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAlertThreshold(int alert) {
|
void setAlertThreshold(int alert) {
|
||||||
|
@ -144,10 +126,28 @@ public class Drug implements Serializable {
|
||||||
this.alertThreshold = alert;
|
this.alertThreshold = alert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getWarnThreshold() {
|
||||||
|
return warnThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWarnThreshold(int warn) {
|
||||||
|
if (warn == 0)
|
||||||
|
warn = 14;
|
||||||
|
this.warnThreshold = warn;
|
||||||
|
}
|
||||||
|
|
||||||
|
long getDateLastUpdate() {
|
||||||
|
return dateLastUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
void setDateLastUpdate(long l) {
|
void setDateLastUpdate(long l) {
|
||||||
this.dateLastUpdate = l;
|
this.dateLastUpdate = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Date getDateEndOfStock() {
|
||||||
|
return dateEndOfStock;
|
||||||
|
}
|
||||||
|
|
||||||
void setDateEndOfStock() {
|
void setDateEndOfStock() {
|
||||||
int numberDayOfTake;
|
int numberDayOfTake;
|
||||||
if (this.take > 0) {
|
if (this.take > 0) {
|
||||||
|
@ -176,6 +176,7 @@ public class Drug implements Serializable {
|
||||||
setDateLastUpdate(new Date().getTime());
|
setDateLastUpdate(new Date().getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class DrugDetailContract extends ActivityResultContract<Intent, Integer>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert result obtained from to O
|
* Convert result obtained from to O
|
||||||
|
*
|
||||||
* @param resultCode Integer
|
* @param resultCode Integer
|
||||||
* @param intent Intent
|
* @param intent Intent
|
||||||
* @return Integer
|
* @return Integer
|
||||||
|
|
|
@ -39,6 +39,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.room.Room;
|
import androidx.room.Room;
|
||||||
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
import com.google.zxing.client.android.BuildConfig;
|
||||||
import com.google.zxing.client.android.Intents;
|
import com.google.zxing.client.android.Intents;
|
||||||
import com.journeyapps.barcodescanner.ScanOptions;
|
import com.journeyapps.barcodescanner.ScanOptions;
|
||||||
|
|
||||||
|
@ -54,8 +55,6 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import com.google.zxing.client.android.BuildConfig;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An activity representing a list of Drugs is activity
|
* An activity representing a list of Drugs is activity
|
||||||
* has different presentations for handset and tablet-size devices. On
|
* has different presentations for handset and tablet-size devices. On
|
||||||
|
@ -65,19 +64,15 @@ import com.google.zxing.client.android.BuildConfig;
|
||||||
* item details side-by-side using two vertical panes.
|
* item details side-by-side using two vertical panes.
|
||||||
*/
|
*/
|
||||||
public class DrugListActivity extends AppCompatActivity {
|
public class DrugListActivity extends AppCompatActivity {
|
||||||
// Used for dev and debug
|
private static final String TAG = DrugListActivity.class.getName();
|
||||||
final Boolean DEMO = false;
|
|
||||||
|
|
||||||
public final int CUSTOMIZED_REQUEST_CODE = 0x0000ffff;
|
public final int CUSTOMIZED_REQUEST_CODE = 0x0000ffff;
|
||||||
public final String BARCODE_FORMAT_NAME = "Barcode Format name";
|
public final String BARCODE_FORMAT_NAME = "Barcode Format name";
|
||||||
public final String BARCODE_CONTENT = "Barcode Content";
|
public final String BARCODE_CONTENT = "Barcode Content";
|
||||||
|
// Used for dev and debug
|
||||||
private ActivityResultLauncher<ScanOptions> mBarcodeScannerLauncher;
|
final Boolean DEMO = false;
|
||||||
private static final String TAG = DrugListActivity.class.getName();
|
|
||||||
|
|
||||||
public PrescriptionDatabase prescriptions;
|
public PrescriptionDatabase prescriptions;
|
||||||
public MedicineDatabase medicines;
|
public MedicineDatabase medicines;
|
||||||
|
private ActivityResultLauncher<ScanOptions> mBarcodeScannerLauncher;
|
||||||
private List<Prescription> prescriptionList; // used for prescriptions
|
private List<Prescription> prescriptionList; // used for prescriptions
|
||||||
|
|
||||||
private RecyclerViewAdapter mAdapter;
|
private RecyclerViewAdapter mAdapter;
|
||||||
|
@ -86,7 +81,7 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
if(BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
String manufacturer = Build.MANUFACTURER;
|
String manufacturer = Build.MANUFACTURER;
|
||||||
String model = Build.MODEL;
|
String model = Build.MODEL;
|
||||||
int version = Build.VERSION.SDK_INT;
|
int version = Build.VERSION.SDK_INT;
|
||||||
|
@ -108,13 +103,13 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
// Manually migrate old database to room
|
// Manually migrate old database to room
|
||||||
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
|
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
|
||||||
DBHelper dbHelper = new DBHelper(this);
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
if (dbHelper.getCount() !=0) {
|
if (dbHelper.getCount() != 0) {
|
||||||
List<Drug> drugs=dbHelper.getAllDrugs();
|
List<Drug> drugs = dbHelper.getAllDrugs();
|
||||||
for (int count=0; count < dbHelper.getCount(); count++) {
|
for (int count = 0; count < dbHelper.getCount(); count++) {
|
||||||
Drug drug = drugs.get(count);
|
Drug drug = drugs.get(count);
|
||||||
Prescription prescription = new Prescription();
|
Prescription prescription = new Prescription();
|
||||||
|
|
||||||
if(prescriptionsDAO.getMedicByCIP13(drug.getCip13()) == null) {
|
if (prescriptionsDAO.getMedicByCIP13(drug.getCip13()) == null) {
|
||||||
prescription.setName(drug.getName());
|
prescription.setName(drug.getName());
|
||||||
prescription.setCip13(drug.getCip13());
|
prescription.setCip13(drug.getCip13());
|
||||||
prescription.setCis(drug.getCis());
|
prescription.setCis(drug.getCis());
|
||||||
|
@ -127,8 +122,7 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
prescription.setLast_update(drug.getDateLastUpdate());
|
prescription.setLast_update(drug.getDateLastUpdate());
|
||||||
|
|
||||||
prescriptionsDAO.insert(prescription);
|
prescriptionsDAO.insert(prescription);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Log.i(TAG, "Already in the database");
|
Log.i(TAG, "Already in the database");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,11 +159,12 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
Log.d(TAG, "onPause");
|
Log.d(TAG, "onPause");
|
||||||
|
|
||||||
if (!AlarmReceiver.isAlarmScheduled(this)){
|
if (!AlarmReceiver.isAlarmScheduled(this)) {
|
||||||
AlarmReceiver.scheduleAlarm(this);
|
AlarmReceiver.scheduleAlarm(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -369,10 +364,12 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
editText.addTextChangedListener(new TextWatcher() {
|
editText.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) { }
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
|
@ -460,6 +457,7 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
||||||
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
|
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setupRecyclerView (list of drugs)
|
* setupRecyclerView (list of drugs)
|
||||||
*
|
*
|
||||||
|
@ -470,7 +468,7 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
mAdapter = new RecyclerViewAdapter(prescriptionList);
|
mAdapter = new RecyclerViewAdapter(prescriptionList);
|
||||||
recyclerView.setAdapter(mAdapter);
|
recyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, (ItemTouchHelper.RIGHT|ItemTouchHelper.LEFT)) {
|
new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, (ItemTouchHelper.RIGHT | ItemTouchHelper.LEFT)) {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
|
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -561,6 +559,16 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAppName() {
|
||||||
|
PackageManager packageManager = getApplicationContext().getPackageManager();
|
||||||
|
ApplicationInfo applicationInfo = null;
|
||||||
|
try {
|
||||||
|
applicationInfo = packageManager.getApplicationInfo(this.getPackageName(), 0);
|
||||||
|
} catch (final PackageManager.NameNotFoundException ignored) {
|
||||||
|
}
|
||||||
|
return (String) ((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo) : "???");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SimpleItemRecyclerViewAdapter
|
* SimpleItemRecyclerViewAdapter
|
||||||
*/
|
*/
|
||||||
|
@ -687,14 +695,4 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAppName() {
|
|
||||||
PackageManager packageManager = getApplicationContext().getPackageManager();
|
|
||||||
ApplicationInfo applicationInfo = null;
|
|
||||||
try {
|
|
||||||
applicationInfo = packageManager.getApplicationInfo(this.getPackageName(), 0);
|
|
||||||
} catch (final PackageManager.NameNotFoundException ignored) {
|
|
||||||
}
|
|
||||||
return (String) ((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo) : "???");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,9 @@ import com.journeyapps.barcodescanner.ScanIntentResult;
|
||||||
import com.journeyapps.barcodescanner.ScanOptions;
|
import com.journeyapps.barcodescanner.ScanOptions;
|
||||||
|
|
||||||
|
|
||||||
public class PilldroidScanContract extends ActivityResultContract<ScanOptions, ScanIntentResult>{
|
public class PilldroidScanContract extends ActivityResultContract<ScanOptions, ScanIntentResult> {
|
||||||
private static final String TAG = PilldroidScanContract.class.getName();
|
private static final String TAG = PilldroidScanContract.class.getName();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Intent createIntent(@NonNull Context context, ScanOptions input) {
|
public Intent createIntent(@NonNull Context context, ScanOptions input) {
|
||||||
|
@ -25,7 +26,7 @@ public class PilldroidScanContract extends ActivityResultContract<ScanOptions, S
|
||||||
intent.setAction(Intents.Scan.ACTION);
|
intent.setAction(Intents.Scan.ACTION);
|
||||||
|
|
||||||
Log.d(TAG, "intent ==" + intent);
|
Log.d(TAG, "intent ==" + intent);
|
||||||
return(intent);
|
return (intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,49 +4,51 @@ package net.foucry.pilldroid;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Lincoln on 05/05/16.
|
* Created by Lincoln on 05/05/16.
|
||||||
*/
|
*/
|
||||||
public class PrefManager {
|
public class PrefManager {
|
||||||
final SharedPreferences pref;
|
|
||||||
SharedPreferences.Editor editor;
|
|
||||||
|
|
||||||
// shared pref mode
|
|
||||||
final int PRIVATE_MODE = 0;
|
|
||||||
|
|
||||||
// Shared preferences file name
|
// Shared preferences file name
|
||||||
private static final String PREF_NAME = "Pildroid-Prefs";
|
private static final String PREF_NAME = "Pildroid-Prefs";
|
||||||
private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
|
private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
|
||||||
private static final String DATABASE_VERSION = "DatabaseVersion";
|
private static final String DATABASE_VERSION = "DatabaseVersion";
|
||||||
private static final String IS_UNDERSTOOD = "IsUnderStood";
|
private static final String IS_UNDERSTOOD = "IsUnderStood";
|
||||||
|
final SharedPreferences pref;
|
||||||
|
// shared pref mode
|
||||||
|
final int PRIVATE_MODE = 0;
|
||||||
|
SharedPreferences.Editor editor;
|
||||||
|
|
||||||
public PrefManager(Context context) {
|
public PrefManager(Context context) {
|
||||||
pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
|
pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFirstTimeLaunch() {
|
||||||
|
return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
|
||||||
|
}
|
||||||
|
|
||||||
public void setFirstTimeLaunch(boolean isFirstTime) {
|
public void setFirstTimeLaunch(boolean isFirstTime) {
|
||||||
editor = pref.edit();
|
editor = pref.edit();
|
||||||
editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
|
editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDatabaseVersion() {
|
||||||
|
return pref.getInt(DATABASE_VERSION, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public void setDatabaseVersion(int version) {
|
public void setDatabaseVersion(int version) {
|
||||||
editor = pref.edit();
|
editor = pref.edit();
|
||||||
editor.putInt(DATABASE_VERSION, version);
|
editor.putInt(DATABASE_VERSION, version);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUnderstood() {
|
||||||
|
return pref.getBoolean(IS_UNDERSTOOD, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void setUnderstood(boolean isUnderstood) {
|
public void setUnderstood(boolean isUnderstood) {
|
||||||
editor = pref.edit();
|
editor = pref.edit();
|
||||||
editor.putBoolean(IS_UNDERSTOOD, isUnderstood);
|
editor.putBoolean(IS_UNDERSTOOD, isUnderstood);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public boolean isFirstTimeLaunch() {
|
|
||||||
return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
|
|
||||||
}
|
|
||||||
public int getDatabaseVersion() {
|
|
||||||
return pref.getInt(DATABASE_VERSION, 0);
|
|
||||||
}
|
|
||||||
public boolean isUnderstood() {return pref.getBoolean(IS_UNDERSTOOD, false); }
|
|
||||||
}
|
|
||||||
|
|
|
@ -86,11 +86,12 @@ public class UtilDate {
|
||||||
Date oldDate = dateAtNoon(date); // Be sure that the old date is at Noon
|
Date oldDate = dateAtNoon(date); // Be sure that the old date is at Noon
|
||||||
Date todayDate = dateAtNoon(new Date()); // Be sure that we use today at Noon
|
Date todayDate = dateAtNoon(new Date()); // Be sure that we use today at Noon
|
||||||
|
|
||||||
return (int) (todayDate.getTime() - oldDate.getTime())/(86400*1000);
|
return (int) (todayDate.getTime() - oldDate.getTime()) / (86400 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert dateInMilliseconds into string formatted date
|
* Convert dateInMilliseconds into string formatted date
|
||||||
|
*
|
||||||
* @param dateInMilliseconds long
|
* @param dateInMilliseconds long
|
||||||
* @return formatted Date String
|
* @return formatted Date String
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -14,21 +14,21 @@ public class Utils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a random number between two values - use to generate a false demo DB
|
* Return a random number between two values - use to generate a false demo DB
|
||||||
|
*
|
||||||
* @param min minimal value accepted
|
* @param min minimal value accepted
|
||||||
* @param max maximum value accepted
|
* @param max maximum value accepted
|
||||||
* @return int random number
|
* @return int random number
|
||||||
*/
|
*/
|
||||||
static int intRandomExclusive(int min, int max) {
|
static int intRandomExclusive(int min, int max) {
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
return r.nextInt(max - min) +max;
|
return r.nextInt(max - min) + max;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String fmt(double d)
|
public static String fmt(double d) {
|
||||||
{
|
if (d == (long) d)
|
||||||
if(d == (long) d)
|
return String.format(Locale.getDefault(), "%d", (long) d);
|
||||||
return String.format(Locale.getDefault(),"%d",(long)d);
|
|
||||||
else
|
else
|
||||||
return String.format("%s",d);
|
return String.format("%s", d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Prescription medicine2prescription(Medicine aMedicine) {
|
public static Prescription medicine2prescription(Medicine aMedicine) {
|
||||||
|
|
|
@ -27,6 +27,35 @@ public class WelcomeActivity extends AppCompatActivity {
|
||||||
private LinearLayout dotsLayout;
|
private LinearLayout dotsLayout;
|
||||||
private int[] layouts;
|
private int[] layouts;
|
||||||
private Button btnSkip, btnNext;
|
private Button btnSkip, btnNext;
|
||||||
|
// viewpager change listener
|
||||||
|
final ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
addBottomDots(position);
|
||||||
|
|
||||||
|
// changing the next button text 'NEXT' / 'GOT IT'
|
||||||
|
if (position == layouts.length - 1) {
|
||||||
|
// last page. make button text to GOT IT
|
||||||
|
btnNext.setText(getString(R.string.start));
|
||||||
|
btnSkip.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
// still pages are left
|
||||||
|
btnNext.setText(getString(R.string.next));
|
||||||
|
btnSkip.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int arg0, float arg1, int arg2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int arg0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
private PrefManager prefManager;
|
private PrefManager prefManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -131,36 +160,6 @@ public class WelcomeActivity extends AppCompatActivity {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
// viewpager change listener
|
|
||||||
final ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int position) {
|
|
||||||
addBottomDots(position);
|
|
||||||
|
|
||||||
// changing the next button text 'NEXT' / 'GOT IT'
|
|
||||||
if (position == layouts.length - 1) {
|
|
||||||
// last page. make button text to GOT IT
|
|
||||||
btnNext.setText(getString(R.string.start));
|
|
||||||
btnSkip.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
// still pages are left
|
|
||||||
btnNext.setText(getString(R.string.next));
|
|
||||||
btnSkip.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int arg0, float arg1, int arg2) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int arg0) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Making notification bar transparent
|
* Making notification bar transparent
|
||||||
*/
|
*/
|
||||||
|
@ -170,16 +169,15 @@ public class WelcomeActivity extends AppCompatActivity {
|
||||||
window.setStatusBarColor(Color.TRANSPARENT);
|
window.setStatusBarColor(Color.TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFullScreen(){
|
private void setFullScreen() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
getWindow().setDecorFitsSystemWindows(false);
|
getWindow().setDecorFitsSystemWindows(false);
|
||||||
WindowInsetsController controller = getWindow().getInsetsController();
|
WindowInsetsController controller = getWindow().getInsetsController();
|
||||||
if(controller != null) {
|
if (controller != null) {
|
||||||
controller.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
|
controller.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
|
||||||
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//noinspection
|
//noinspection
|
||||||
getWindow().getDecorView().setSystemUiVisibility(
|
getWindow().getDecorView().setSystemUiVisibility(
|
||||||
View.SYSTEM_UI_FLAG_FULLSCREEN
|
View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
|
|
|
@ -16,7 +16,7 @@ import net.foucry.pilldroid.models.Medicine;
|
||||||
|
|
||||||
public abstract class MedicineDatabase extends RoomDatabase {
|
public abstract class MedicineDatabase extends RoomDatabase {
|
||||||
private static MedicineDatabase INSTANCE;
|
private static MedicineDatabase INSTANCE;
|
||||||
public abstract MedicinesDAO getMedicinesDAO();
|
|
||||||
public static MedicineDatabase getInstanceDatabase(Context context) {
|
public static MedicineDatabase getInstanceDatabase(Context context) {
|
||||||
if (INSTANCE == null) {
|
if (INSTANCE == null) {
|
||||||
INSTANCE =
|
INSTANCE =
|
||||||
|
@ -32,4 +32,6 @@ public abstract class MedicineDatabase extends RoomDatabase {
|
||||||
public static void destroyInstance() {
|
public static void destroyInstance() {
|
||||||
INSTANCE = null;
|
INSTANCE = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract MedicinesDAO getMedicinesDAO();
|
||||||
}
|
}
|
|
@ -28,11 +28,6 @@ import net.foucry.pilldroid.models.Prescription;
|
||||||
public abstract class PrescriptionDatabase extends RoomDatabase {
|
public abstract class PrescriptionDatabase extends RoomDatabase {
|
||||||
private static PrescriptionDatabase INSTANCE;
|
private static PrescriptionDatabase INSTANCE;
|
||||||
|
|
||||||
public abstract PrescriptionsDAO getPrescriptionsDAO();
|
|
||||||
|
|
||||||
@RenameColumn(tableName = "prescriptions", fromColumnName = "genetic_type", toColumnName = "generic_type")
|
|
||||||
static class generic_typeMigration implements AutoMigrationSpec { }
|
|
||||||
|
|
||||||
public static PrescriptionDatabase getInstanceDatabase(Context context) {
|
public static PrescriptionDatabase getInstanceDatabase(Context context) {
|
||||||
if (INSTANCE == null) {
|
if (INSTANCE == null) {
|
||||||
INSTANCE =
|
INSTANCE =
|
||||||
|
@ -44,7 +39,14 @@ public abstract class PrescriptionDatabase extends RoomDatabase {
|
||||||
}
|
}
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void destroyInstance() {
|
public static void destroyInstance() {
|
||||||
INSTANCE = null;
|
INSTANCE = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract PrescriptionsDAO getPrescriptionsDAO();
|
||||||
|
|
||||||
|
@RenameColumn(tableName = "prescriptions", fromColumnName = "genetic_type", toColumnName = "generic_type")
|
||||||
|
static class generic_typeMigration implements AutoMigrationSpec {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@ import androidx.room.PrimaryKey;
|
||||||
@Entity(tableName = "drugs")
|
@Entity(tableName = "drugs")
|
||||||
public class Medicine {
|
public class Medicine {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@NonNull private Integer _id;
|
@NonNull
|
||||||
|
private Integer _id;
|
||||||
private String cis;
|
private String cis;
|
||||||
private String cip13;
|
private String cip13;
|
||||||
private String cip7;
|
private String cip7;
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package net.foucry.pilldroid.models;
|
package net.foucry.pilldroid.models;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.room.Entity;
|
import androidx.room.Entity;
|
||||||
import androidx.room.PrimaryKey;
|
import androidx.room.PrimaryKey;
|
||||||
|
@ -15,7 +12,7 @@ import java.util.Date;
|
||||||
|
|
||||||
@Entity(tableName = "prescriptions")
|
@Entity(tableName = "prescriptions")
|
||||||
public class Prescription implements Serializable {
|
public class Prescription implements Serializable {
|
||||||
private static final String TAG = Prescription.class.getName();;
|
private static final String TAG = Prescription.class.getName();
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@NonNull
|
@NonNull
|
||||||
private String cis;
|
private String cis;
|
||||||
|
@ -31,87 +28,87 @@ public class Prescription implements Serializable {
|
||||||
private String label_group;
|
private String label_group;
|
||||||
private Integer generic_type;
|
private Integer generic_type;
|
||||||
|
|
||||||
public void setCis(@NonNull String cis) {
|
|
||||||
this.cis = cis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCip13(String cip13) {
|
|
||||||
this.cip13 = cip13;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdministration_mode(String administration_mode) {
|
|
||||||
this.administration_mode = administration_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPresentation(String presentation) {
|
|
||||||
this.presentation = presentation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStock(Float stock) {
|
|
||||||
this.stock = stock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTake(Float take) {
|
|
||||||
this.take = take;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWarning(Integer warning) {
|
|
||||||
this.warning = warning;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlert(Integer alert) {
|
|
||||||
this.alert = alert;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLast_update(Long last_update) {
|
|
||||||
this.last_update = last_update;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public String getCis() {
|
public String getCis() {
|
||||||
return this.cis;
|
return this.cis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCis(@NonNull String cis) {
|
||||||
|
this.cis = cis;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getWarning() {
|
public Integer getWarning() {
|
||||||
return warning;
|
return warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setWarning(Integer warning) {
|
||||||
|
this.warning = warning;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCip13() {
|
public String getCip13() {
|
||||||
return cip13;
|
return cip13;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCip13(String cip13) {
|
||||||
|
this.cip13 = cip13;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAdministration_mode() {
|
public String getAdministration_mode() {
|
||||||
return administration_mode;
|
return administration_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAdministration_mode(String administration_mode) {
|
||||||
|
this.administration_mode = administration_mode;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPresentation() {
|
public String getPresentation() {
|
||||||
return presentation;
|
return presentation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPresentation(String presentation) {
|
||||||
|
this.presentation = presentation;
|
||||||
|
}
|
||||||
|
|
||||||
public Float getStock() {
|
public Float getStock() {
|
||||||
return stock;
|
return stock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStock(Float stock) {
|
||||||
|
this.stock = stock;
|
||||||
|
}
|
||||||
|
|
||||||
public Float getTake() {
|
public Float getTake() {
|
||||||
return take;
|
return take;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTake(Float take) {
|
||||||
|
this.take = take;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getAlert() {
|
public Integer getAlert() {
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAlert(Integer alert) {
|
||||||
|
this.alert = alert;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getLast_update() {
|
public Long getLast_update() {
|
||||||
return last_update;
|
return last_update;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLast_update(Long last_update) {
|
||||||
|
this.last_update = last_update;
|
||||||
|
}
|
||||||
|
|
||||||
public int getAlertThreshold() {
|
public int getAlertThreshold() {
|
||||||
return this.alert;
|
return this.alert;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<translate android:fromXDelta="-100%p" android:toXDelta="0"
|
<translate
|
||||||
|
android:duration="@integer/slide_animation_duration"
|
||||||
|
android:fromXDelta="-100%p"
|
||||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||||
android:duration="@integer/slide_animation_duration"/>
|
android:toXDelta="0" />
|
||||||
</set>
|
</set>
|
|
@ -1,6 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<translate android:fromXDelta="100%p" android:toXDelta="0"
|
<translate
|
||||||
|
android:duration="@integer/slide_animation_duration"
|
||||||
|
android:fromXDelta="100%p"
|
||||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||||
android:duration="@integer/slide_animation_duration"/>
|
android:toXDelta="0" />
|
||||||
</set>
|
</set>
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<translate android:fromXDelta="0" android:toXDelta="-100%p"
|
<translate android:duration="@integer/slide_animation_duration" android:fromXDelta="0"
|
||||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||||
android:duration="@integer/slide_animation_duration"/>
|
android:toXDelta="-100%p"/>
|
||||||
</set>
|
</set>
|
|
@ -1,6 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<translate android:fromXDelta="0" android:toXDelta="100%p"
|
<translate
|
||||||
|
android:duration="@integer/slide_animation_duration"
|
||||||
|
android:fromXDelta="0"
|
||||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||||
android:duration="@integer/slide_animation_duration"/>
|
android:toXDelta="100%p" />
|
||||||
</set>
|
</set>
|
|
@ -1,9 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical" android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@android:color/white"
|
android:background="@android:color/white"
|
||||||
|
android:orientation="vertical"
|
||||||
tools:ignore="Overdraw">
|
tools:ignore="Overdraw">
|
||||||
|
|
||||||
<WebView
|
<WebView
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
<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"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<com.journeyapps.barcodescanner.BarcodeView
|
<com.journeyapps.barcodescanner.BarcodeView
|
||||||
|
android:id="@+id/zxing_barcode_surface"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/zxing_barcode_surface"
|
app:zxing_framing_rect_height="150dp"
|
||||||
app:zxing_framing_rect_width="300dp"
|
app:zxing_framing_rect_width="300dp"></com.journeyapps.barcodescanner.BarcodeView>
|
||||||
app:zxing_framing_rect_height="150dp">
|
|
||||||
</com.journeyapps.barcodescanner.BarcodeView>
|
|
||||||
|
|
||||||
<com.journeyapps.barcodescanner.ViewfinderView
|
<com.journeyapps.barcodescanner.ViewfinderView
|
||||||
android:id="@+id/zxing_viewfinder_view"
|
android:id="@+id/zxing_viewfinder_view"
|
||||||
|
@ -20,7 +19,7 @@
|
||||||
app:zxing_result_view="@color/zxing_custom_result_view"
|
app:zxing_result_view="@color/zxing_custom_result_view"
|
||||||
app:zxing_viewfinder_laser="@color/zxing_custom_viewfinder_laser"
|
app:zxing_viewfinder_laser="@color/zxing_custom_viewfinder_laser"
|
||||||
app:zxing_viewfinder_laser_visibility="true"
|
app:zxing_viewfinder_laser_visibility="true"
|
||||||
app:zxing_viewfinder_mask="@color/grey"/>
|
app:zxing_viewfinder_mask="@color/grey" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/zxing_status_view"
|
android:id="@+id/zxing_status_view"
|
||||||
|
@ -30,10 +29,10 @@
|
||||||
android:layout_marginTop="@dimen/app_bar_height"
|
android:layout_marginTop="@dimen/app_bar_height"
|
||||||
android:background="@color/zxing_transparent"
|
android:background="@color/zxing_transparent"
|
||||||
android:fontFamily="sans-serif-black"
|
android:fontFamily="sans-serif-black"
|
||||||
android:textSize="32sp"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:text="@string/zxing_msg_default_status"
|
android:text="@string/zxing_msg_default_status"
|
||||||
|
android:textAlignment="center"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
|
android:textSize="32sp"
|
||||||
tools:ignore="PrivateResource" />
|
tools:ignore="PrivateResource" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="net.foucry.pilldroid.CustomScannerActivity">
|
tools:context="net.foucry.pilldroid.CustomScannerActivity">
|
||||||
|
|
|
@ -8,43 +8,43 @@
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/name_cell"
|
android:id="@+id/name_cell"
|
||||||
|
layout="@layout/info_cell"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
layout="@layout/info_cell" />
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/presentation_cell"
|
android:id="@+id/presentation_cell"
|
||||||
|
layout="@layout/info_cell"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
layout="@layout/info_cell"/>
|
<!-- android:layout_marginTop="5sp" />-->
|
||||||
<!-- android:layout_marginTop="5sp" />-->
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/administration_cell"
|
android:id="@+id/administration_cell"
|
||||||
|
layout="@layout/info_cell"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
layout="@layout/info_cell"/>
|
<!-- android:layout_marginTop="5sp" />-->
|
||||||
<!-- android:layout_marginTop="5sp" />-->
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/stock_cell"
|
android:id="@+id/stock_cell"
|
||||||
|
layout="@layout/value_input"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
layout="@layout/value_input"/>
|
<!-- android:layout_marginTop="30sp" />-->
|
||||||
<!-- android:layout_marginTop="30sp" />-->
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/take_cell"
|
android:id="@+id/take_cell"
|
||||||
layout="@layout/value_input"
|
layout="@layout/value_input"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/warning_cell"
|
android:id="@+id/warning_cell"
|
||||||
|
layout="@layout/value_input"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
layout="@layout/value_input"/>
|
<!-- android:layout_marginTop="15sp" />-->
|
||||||
<!-- android:layout_marginTop="15sp" />-->
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/alert_cell"
|
android:id="@+id/alert_cell"
|
||||||
|
|
|
@ -49,9 +49,9 @@
|
||||||
android:layout_height="@dimen/fab_height"
|
android:layout_height="@dimen/fab_height"
|
||||||
android:layout_gravity="end|bottom"
|
android:layout_gravity="end|bottom"
|
||||||
android:layout_marginTop="?attr/actionBarSize"
|
android:layout_marginTop="?attr/actionBarSize"
|
||||||
android:layout_marginBottom="?attr/actionBarSize"
|
|
||||||
android:layout_marginEnd="@dimen/fab_margin"
|
android:layout_marginEnd="@dimen/fab_margin"
|
||||||
|
android:layout_marginBottom="?attr/actionBarSize"
|
||||||
android:contentDescription="@string/save_button"
|
android:contentDescription="@string/save_button"
|
||||||
android:src="@drawable/ic_save_black_24dp"
|
android:src="@drawable/ic_save_black_24dp"
|
||||||
app:backgroundTint="@android:color/transparent"/>
|
app:backgroundTint="@android:color/transparent" />
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
android:name="net.foucry.pilldroid.MedicamentListFragment"
|
android:name="net.foucry.pilldroid.MedicamentListFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layoutManager="LinearLayoutManager"
|
|
||||||
android:background="@drawable/list_selector"
|
android:background="@drawable/list_selector"
|
||||||
|
app:layoutManager="LinearLayoutManager"
|
||||||
tools:context="net.foucry.pilldroid.DrugListActivity"
|
tools:context="net.foucry.pilldroid.DrugListActivity"
|
||||||
tools:listitem="@layout/drug_list_content" />
|
tools:listitem="@layout/drug_list_content" />
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/drug_list"
|
layout="@layout/drug_list"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"/>
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
@ -45,11 +45,11 @@
|
||||||
android:backgroundTint="@android:color/transparent"
|
android:backgroundTint="@android:color/transparent"
|
||||||
android:baselineAlignBottom="false"
|
android:baselineAlignBottom="false"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
|
android:contentDescription="@string/add_button"
|
||||||
android:onClick="onButtonClick"
|
android:onClick="onButtonClick"
|
||||||
android:src="@drawable/ic_add_circle_black_24dp"
|
android:src="@drawable/ic_add_circle_black_24dp"
|
||||||
app:backgroundTint="@android:color/darker_gray"
|
app:backgroundTint="@android:color/darker_gray"
|
||||||
app:fabCustomSize="60dp"
|
app:fabCustomSize="60dp"
|
||||||
app:maxImageSize="60dp"
|
app:maxImageSize="60dp"
|
||||||
android:contentDescription="@string/add_button"
|
|
||||||
tools:ignore="OnClick" />
|
tools:ignore="OnClick" />
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
|
@ -13,24 +13,24 @@
|
||||||
android:id="@+id/list_image"
|
android:id="@+id/list_image"
|
||||||
android:layout_width="50sp"
|
android:layout_width="50sp"
|
||||||
android:layout_height="50sp"
|
android:layout_height="50sp"
|
||||||
android:layout_marginStart="5dp"
|
android:layout_alignParentStart="true"
|
||||||
android:src="@drawable/ok_stock_vect"
|
|
||||||
android:contentDescription="@string/stockIcon"
|
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_alignParentStart="true" />
|
android:layout_marginStart="5dp"
|
||||||
|
android:contentDescription="@string/stockIcon"
|
||||||
|
android:src="@drawable/ok_stock_vect" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/value"
|
android:id="@+id/value"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignTop="@+id/list_image"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_toEndOf="@+id/list_image"
|
||||||
android:text="@string/drugName"
|
android:text="@string/drugName"
|
||||||
android:textColor="#040404"
|
android:textColor="#040404"
|
||||||
android:typeface="sans"
|
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_alignTop="@+id/list_image"
|
android:typeface="sans" />
|
||||||
android:layout_toEndOf="@+id/list_image"
|
|
||||||
android:layout_marginStart="5dp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/endOfStock"
|
android:id="@+id/endOfStock"
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/list_selector">
|
android:background="@drawable/list_selector"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/value"
|
android:id="@+id/value"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="10sp"
|
android:paddingStart="10sp"
|
||||||
android:paddingEnd="10sp"
|
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
|
android:paddingEnd="10sp"
|
||||||
android:text="@string/Value"
|
android:text="@string/Value"
|
||||||
android:textColor="#040404"
|
android:textColor="#040404"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/list_selector"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:background="@drawable/list_selector"
|
|
||||||
android:weightSum="1">
|
android:weightSum="1">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label"
|
android:id="@+id/label"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -31,14 +32,14 @@
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:gravity="end|fill_vertical"
|
android:gravity="end|fill_vertical"
|
||||||
|
android:hint="@string/zero"
|
||||||
|
android:importantForAutofill="no"
|
||||||
android:inputType="numberDecimal"
|
android:inputType="numberDecimal"
|
||||||
android:labelFor="@id/value"
|
android:labelFor="@id/value"
|
||||||
android:paddingEnd="25dp"
|
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
android:hint="@string/zero"
|
android:paddingEnd="25dp"
|
||||||
android:textColorHint="@color/grey"
|
|
||||||
android:textAlignment="gravity"
|
android:textAlignment="gravity"
|
||||||
android:importantForAutofill="no"
|
android:textColorHint="@color/grey"
|
||||||
tools:ignore="LabelFor" />
|
tools:ignore="LabelFor" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -19,20 +19,19 @@
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_marginBottom="@dimen/dots_margin_bottom"
|
android:layout_marginBottom="@dimen/dots_margin_bottom"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"></LinearLayout>
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_next"
|
android:id="@+id/btn_next"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_marginBottom="@dimen/dots_margin_bottom"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:text="@string/next"
|
android:text="@string/next"
|
||||||
android:layout_marginBottom="@dimen/dots_margin_bottom"
|
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
tools:ignore="RelativeOverlap,RtlSymmetry"/>
|
tools:ignore="RelativeOverlap,RtlSymmetry" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_skip"
|
android:id="@+id/btn_skip"
|
||||||
|
@ -43,5 +42,5 @@
|
||||||
android:layout_marginBottom="@dimen/dots_margin_bottom"
|
android:layout_marginBottom="@dimen/dots_margin_bottom"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:text="@string/skip"
|
android:text="@string/skip"
|
||||||
android:textColor="@android:color/white"/>
|
android:textColor="@android:color/white" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
Loading…
Reference in a new issue