From e3b977a6e19ee38bf4a3815f1485076e9ae5e3ac Mon Sep 17 00:00:00 2001 From: jacques Date: Wed, 23 Dec 2020 09:48:08 +0100 Subject: [PATCH] Amisc --- .../java/net/foucry/pilldroid/DBHelper.java | 11 +++++++---- .../java/net/foucry/pilldroid/Medicament.java | 10 +++++----- .../pilldroid/MedicamentListActivity.java | 12 ++++++------ .../foucry/pilldroid/PillDroidJobService.java | 9 ++++----- app/src/main/res/drawable/ic_pill.xml | 9 --------- app/src/main/res/drawable/lower_stock.svg | 15 --------------- ...lower_stock.png => lower_stock_bitmap.png} | Bin .../{lower_stock.xml => lower_stock_vect.xml} | 0 app/src/main/res/drawable/ok_stock.svg | 14 -------------- .../{ok_stock.png => ok_stock_bitmap.png} | Bin .../{ok_stock.xml => ok_stock_vect.xml} | 0 app/src/main/res/drawable/warning_stock.svg | 18 ------------------ ...ing_stock.png => warning_stock_bitmap.png} | Bin ...rning_stock.xml => warning_stock_vect.xml} | 0 .../res/layout/medicament_list_content.xml | 2 +- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 17 files changed, 27 insertions(+), 81 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_pill.xml delete mode 100644 app/src/main/res/drawable/lower_stock.svg rename app/src/main/res/drawable/{lower_stock.png => lower_stock_bitmap.png} (100%) rename app/src/main/res/drawable/{lower_stock.xml => lower_stock_vect.xml} (100%) delete mode 100644 app/src/main/res/drawable/ok_stock.svg rename app/src/main/res/drawable/{ok_stock.png => ok_stock_bitmap.png} (100%) rename app/src/main/res/drawable/{ok_stock.xml => ok_stock_vect.xml} (100%) delete mode 100644 app/src/main/res/drawable/warning_stock.svg rename app/src/main/res/drawable/{warning_stock.png => warning_stock_bitmap.png} (100%) rename app/src/main/res/drawable/{warning_stock.xml => warning_stock_vect.xml} (100%) diff --git a/app/src/main/java/net/foucry/pilldroid/DBHelper.java b/app/src/main/java/net/foucry/pilldroid/DBHelper.java index 2fa0902..a924872 100644 --- a/app/src/main/java/net/foucry/pilldroid/DBHelper.java +++ b/app/src/main/java/net/foucry/pilldroid/DBHelper.java @@ -21,7 +21,6 @@ import java.util.List; class DBHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; - @SuppressWarnings("CanBeFinal") private static final ThreadLocal DATABASE_NAME = ThreadLocal.withInitial(() -> "ordonnance.db"); private static final String TABLE_DRUG = "drug"; @@ -264,11 +263,15 @@ class DBHelper extends SQLiteOpenHelper { Medicament currentMedicament; for (int position = 0 ; position < getCount() ; position++ ) { currentMedicament = getItem(position); - currentMedicament.newStock(currentMedicament.getStock()); - updateDrug(currentMedicament); + +// if (!DateUtils.isToday(currentMedicament.getDateLastUpdate())) +// { + currentMedicament.newStock(); + updateDrug(currentMedicament); + //} } - Collections.sort(medicaments, new Comparator() { + medicaments.sort(new Comparator() { @Override public int compare(Medicament lhs, Medicament rhs) { return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock()); diff --git a/app/src/main/java/net/foucry/pilldroid/Medicament.java b/app/src/main/java/net/foucry/pilldroid/Medicament.java index 38bb20d..102e09a 100644 --- a/app/src/main/java/net/foucry/pilldroid/Medicament.java +++ b/app/src/main/java/net/foucry/pilldroid/Medicament.java @@ -160,11 +160,11 @@ public class Medicament implements Serializable { this.dateEndOfStock = calendar.getTime(); } - double newStock(double currentStock) { - Date lastUpdate = string2Date(this.dateLastUpdate); + void newStock() { + Date lastUpdate = new Date(getDateLastUpdate()); int numberOfDays = nbOfDaysBetweenDateAndToday(lastUpdate); double takeDuringPeriod = this.prise * numberOfDays; - - return currentStock - takeDuringPeriod; + setStock(getStock() - takeDuringPeriod); + setDateLastUpdate(dateAtNoon(new Date()).getTime()); } -} +} \ No newline at end of file diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java index 40340d2..c162170 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java @@ -500,14 +500,14 @@ public class MedicamentListActivity extends AppCompatActivity { int remainingStock = (int) Math.floor(mValues.get(position).getStock() / mValues.get(position).getPrise()); if (remainingStock <= mValues.get(position).getAlertThreshold()) { holder.mView.setBackgroundResource(R.drawable.gradient_bg_alert); - holder.mIconView.setImageResource(R.drawable.lower_stock); + holder.mIconView.setImageResource(R.drawable.lower_stock_vect); } else if ((remainingStock > mValues.get(position).getAlertThreshold()) && (remainingStock <= (mValues.get(position).getWarnThreshold()))) { holder.mView.setBackgroundResource(R.drawable.gradient_bg_warning); - holder.mIconView.setImageResource(R.drawable.warning_stock); + holder.mIconView.setImageResource(R.drawable.warning_stock_vect); } else { holder.mView.setBackgroundResource(R.drawable.gradient_bg_ok); - holder.mIconView.setImageResource(R.drawable.ok_stock); + holder.mIconView.setImageResource(R.drawable.ok_stock_vect); } } @@ -596,15 +596,15 @@ public class MedicamentListActivity extends AppCompatActivity { TutorialItem tutorialItem5 = new TutorialItem(context.getString(R.string.slide5_Pilldroid), context.getString(R.string.slide5_Pilldroid), - R.color.slide_3, R.drawable.emoticon_happy_outline); + R.color.slide_3, R.drawable.ok_stock_bitmap); TutorialItem tutorialItem6 = new TutorialItem(context.getString(R.string.slide6_Pilldroid), context.getString(R.string.slide6_Pilldroid), - R.color.slide_2, R.drawable.emoticon_neutral_outline); + R.color.slide_2, R.drawable.lower_stock_bitmap); TutorialItem tutorialItem7 = new TutorialItem(context.getString(R.string.slide7_Pilldroid), context.getString(R.string.slide7_Pilldroid), - R.color.slide_4, R.drawable.emoticon_angry_outline); + R.color.slide_4, R.drawable.warning_stock_bitmap); TutorialItem tutorialItem8 = new TutorialItem(context.getString(R.string.slide8_Pilldroid), context.getString(R.string.slide8_Pilldroid), diff --git a/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java b/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java index 11bd0f4..7a8d382 100644 --- a/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java +++ b/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java @@ -4,8 +4,8 @@ import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.job.JobParameters; import android.app.job.JobService; -import android.content.Intent; -import android.icu.util.Calendar; +import android.content.Context; +import android.os.Build; import android.util.Log; import androidx.core.app.NotificationCompat; @@ -20,8 +20,7 @@ import java.util.List; public class PillDroidJobService extends JobService { private static final String TAG = JobService.class.getName(); private boolean jobCancelled = false; - private String CHANNEL_ID = "PillDroid"; - private DBHelper dbHelper = new DBHelper(this); + private final DBHelper dbHelper = new DBHelper(this); @Override @@ -84,7 +83,7 @@ public class PillDroidJobService extends JobService { Intent intent = new Intent(this, MedicamentListActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,0); NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID) - .setSmallIcon(R.drawable.ic_pill) + .setSmallIcon(R.drawable.ic_pill_alarm) .setContentTitle(getString(R.string.app_name)) .setContentText(getString(R.string.notification_text)) .setPriority(NotificationCompat.PRIORITY_DEFAULT) diff --git a/app/src/main/res/drawable/ic_pill.xml b/app/src/main/res/drawable/ic_pill.xml deleted file mode 100644 index 026fdf4..0000000 --- a/app/src/main/res/drawable/ic_pill.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/lower_stock.svg b/app/src/main/res/drawable/lower_stock.svg deleted file mode 100644 index 3dd244c..0000000 --- a/app/src/main/res/drawable/lower_stock.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - diff --git a/app/src/main/res/drawable/lower_stock.png b/app/src/main/res/drawable/lower_stock_bitmap.png similarity index 100% rename from app/src/main/res/drawable/lower_stock.png rename to app/src/main/res/drawable/lower_stock_bitmap.png diff --git a/app/src/main/res/drawable/lower_stock.xml b/app/src/main/res/drawable/lower_stock_vect.xml similarity index 100% rename from app/src/main/res/drawable/lower_stock.xml rename to app/src/main/res/drawable/lower_stock_vect.xml diff --git a/app/src/main/res/drawable/ok_stock.svg b/app/src/main/res/drawable/ok_stock.svg deleted file mode 100644 index 667f578..0000000 --- a/app/src/main/res/drawable/ok_stock.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - diff --git a/app/src/main/res/drawable/ok_stock.png b/app/src/main/res/drawable/ok_stock_bitmap.png similarity index 100% rename from app/src/main/res/drawable/ok_stock.png rename to app/src/main/res/drawable/ok_stock_bitmap.png diff --git a/app/src/main/res/drawable/ok_stock.xml b/app/src/main/res/drawable/ok_stock_vect.xml similarity index 100% rename from app/src/main/res/drawable/ok_stock.xml rename to app/src/main/res/drawable/ok_stock_vect.xml diff --git a/app/src/main/res/drawable/warning_stock.svg b/app/src/main/res/drawable/warning_stock.svg deleted file mode 100644 index 7f2baab..0000000 --- a/app/src/main/res/drawable/warning_stock.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/drawable/warning_stock.png b/app/src/main/res/drawable/warning_stock_bitmap.png similarity index 100% rename from app/src/main/res/drawable/warning_stock.png rename to app/src/main/res/drawable/warning_stock_bitmap.png diff --git a/app/src/main/res/drawable/warning_stock.xml b/app/src/main/res/drawable/warning_stock_vect.xml similarity index 100% rename from app/src/main/res/drawable/warning_stock.xml rename to app/src/main/res/drawable/warning_stock_vect.xml diff --git a/app/src/main/res/layout/medicament_list_content.xml b/app/src/main/res/layout/medicament_list_content.xml index 07806dc..600a17d 100644 --- a/app/src/main/res/layout/medicament_list_content.xml +++ b/app/src/main/res/layout/medicament_list_content.xml @@ -14,7 +14,7 @@ android:layout_width="50sp" android:layout_height="50sp" android:layout_marginStart="5dp" - android:src="@drawable/ok_stock" + android:src="@drawable/ok_stock_vect" android:contentDescription="Icone de stock" android:layout_centerVertical="true" android:layout_alignParentStart="true" /> diff --git a/build.gradle b/build.gradle index 8c316f2..ed69a2d 100644 --- a/build.gradle +++ b/build.gradle @@ -16,8 +16,8 @@ buildscript { } } ext { - compileSdkVersion = '27' - buildToolsVersion = '27.0.1' + compileSdkVersion = '28' + buildToolsVersion = '28.0.1' var = '3.4.2' buildToolsVersion1 = '29.0.3' defaultMinSdkVersion = 28 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d533ba7..9717157 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Apr 24 16:50:40 UTC 2020 +#Tue Nov 03 18:11:12 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip