diff --git a/app/build.gradle b/app/build.gradle index e971d73..6c54c5f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 27 + compileSdkVersion 29 defaultConfig { applicationId "net.foucry.pilldroid" minSdkVersion 25 diff --git a/app/src/main/java/net/foucry/pilldroid/About.java b/app/src/main/java/net/foucry/pilldroid/About.java index f9cfbe3..d03042a 100644 --- a/app/src/main/java/net/foucry/pilldroid/About.java +++ b/app/src/main/java/net/foucry/pilldroid/About.java @@ -48,6 +48,7 @@ public class About extends AppCompatActivity{ // Drawable d = getResources().getDrawable(id); //Drawable d = ResourcesCompatApi21.getDrawable(getResources(),id, null); Drawable d = ContextCompat.getDrawable(getApplicationContext(),id); + assert d != null; d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); return d; } diff --git a/app/src/main/java/net/foucry/pilldroid/DBMedoc.java b/app/src/main/java/net/foucry/pilldroid/DBMedoc.java index a62123f..6a7723f 100644 --- a/app/src/main/java/net/foucry/pilldroid/DBMedoc.java +++ b/app/src/main/java/net/foucry/pilldroid/DBMedoc.java @@ -24,7 +24,7 @@ class DBMedoc extends SQLiteOpenHelper{ private static String dbName = "medicaments.db"; private SQLiteDatabase myDataBase; private final Context myContext; - File dbFile = new File(DATABASE_PATH + dbName); + private File dbFile = new File(DATABASE_PATH + dbName); private static final String TABLE_NAME = "medicaments"; private static final String MEDOC_CIS = "cis"; @@ -54,10 +54,9 @@ class DBMedoc extends SQLiteOpenHelper{ @Override public synchronized SQLiteDatabase getReadableDatabase() { - if (!dbFile.exists()) { - SQLiteDatabase db = super.getReadableDatabase(); - copyDatabase(db.getPath()); - } + if (dbFile.exists()) return super.getReadableDatabase(); + SQLiteDatabase db = super.getReadableDatabase(); + copyDatabase(db.getPath()); return super.getReadableDatabase(); } diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java index b35d32f..2d2f8e4 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentDetailFragment.java @@ -1,5 +1,6 @@ package net.foucry.pilldroid; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.support.design.widget.CollapsingToolbarLayout; @@ -50,13 +51,14 @@ public class MedicamentDetailFragment extends Fragment { medicament = (Medicament) getArguments().getSerializable(ARG_ITEM_ID); Activity activity = this.getActivity(); - CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout); + CollapsingToolbarLayout appBarLayout = activity.findViewById(R.id.toolbar_layout); if (appBarLayout != null) { appBarLayout.setTitle(medicament.getNom()); } } } + @SuppressLint("SetTextI18n") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View detailView = inflater.inflate(R.layout.medicament_detail, container, false); @@ -102,8 +104,8 @@ public class MedicamentDetailFragment extends Fragment { priseValue.setText(Double.toString(medicament.getPrise())); warningView = detailView.findViewById(R.id.warning_cell); - TextView warningLibelle = (TextView) warningView.findViewById(R.id.libelle); - TextView warningValue = (TextView) warningView.findViewById(R.id.valeur); + TextView warningLibelle = warningView.findViewById(R.id.libelle); + TextView warningValue = warningView.findViewById(R.id.valeur); warningLibelle.setText("Seuil d'alerte"); warningValue.setText(Integer.toString(medicament.getWarnThreshold())); @@ -129,6 +131,7 @@ public class MedicamentDetailFragment extends Fragment { View warningView; View alertView; + assert currentView != null; stockView = currentView.findViewById(R.id.stock_cell); TextView stockTextView = stockView.findViewById(R.id.valeur); String stockValue = stockTextView.getText().toString(); diff --git a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java index 6b2bf94..e896b01 100644 --- a/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/MedicamentListActivity.java @@ -276,9 +276,11 @@ public class MedicamentListActivity extends AppCompatActivity { 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); } @@ -475,6 +477,7 @@ public class MedicamentListActivity extends AppCompatActivity { mIconView = view.findViewById(R.id.list_image); } + @NonNull @Override public String toString() { return super.toString() + " '" + mContentView.getText() + "'"; diff --git a/app/src/main/java/net/foucry/pilldroid/SimpleDividerItemDecoration.java b/app/src/main/java/net/foucry/pilldroid/SimpleDividerItemDecoration.java index e84e75b..f5206ad 100644 --- a/app/src/main/java/net/foucry/pilldroid/SimpleDividerItemDecoration.java +++ b/app/src/main/java/net/foucry/pilldroid/SimpleDividerItemDecoration.java @@ -12,8 +12,8 @@ import android.view.View; public class SimpleDividerItemDecoration extends RecyclerView.ItemDecoration { private Drawable mDivider; - public SimpleDividerItemDecoration(Context context) { - mDivider = context.getResources().getDrawable(R.drawable.line_divider); + SimpleDividerItemDecoration(Context context) { + mDivider = context.getDrawable(R.drawable.line_divider); } @Override diff --git a/app/src/main/java/net/foucry/pilldroid/UtilDate.java b/app/src/main/java/net/foucry/pilldroid/UtilDate.java index e513ae8..145ff2b 100644 --- a/app/src/main/java/net/foucry/pilldroid/UtilDate.java +++ b/app/src/main/java/net/foucry/pilldroid/UtilDate.java @@ -94,22 +94,6 @@ class UtilDate { return (int) (todayDate.getTime() - oldDate.getTime()); } - /** - * @param: none - * return int - */ - - static long tomorrowAtNoonInMillis() { - Date now = new Date(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(now); - calendar.add(Calendar.DAY_OF_YEAR,1); - - Date tomorrowAtNoon = dateAtNoon(calendar.getTime()); - - return (tomorrowAtNoon.getTime() - now.getTime()); - } - static String convertDate(long dateInMilliseconds) { DateFormat formatter = new SimpleDateFormat("dd/MM/yy HH:mm:ss", Locale.FRANCE); Calendar calendar = Calendar.getInstance(); diff --git a/app/src/main/java/net/foucry/pilldroid/Utils.java b/app/src/main/java/net/foucry/pilldroid/Utils.java index 11a5d19..41989aa 100644 --- a/app/src/main/java/net/foucry/pilldroid/Utils.java +++ b/app/src/main/java/net/foucry/pilldroid/Utils.java @@ -3,9 +3,7 @@ package net.foucry.pilldroid; import java.io.InputStream; import java.io.OutputStream; -import java.util.Date; import java.util.Random; -import java.lang.Math; public class Utils { public static void CopyStream(InputStream is, OutputStream os) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8c344a9..d533ba7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Apr 12 14:00:20 UTC 2020 +#Fri Apr 24 16:50:40 UTC 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip