diff --git a/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java index 7e3c5ab..3993f11 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java @@ -6,12 +6,12 @@ import android.util.Log; import android.view.MenuItem; import android.view.View; import android.widget.EditText; -import android.widget.ImageButton; import android.widget.TextView; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import com.google.android.material.appbar.MaterialToolbar; +import com.google.android.material.floatingactionbutton.FloatingActionButton; import net.foucry.pilldroid.dao.PrescriptionsDAO; import net.foucry.pilldroid.databases.PrescriptionDatabase; import net.foucry.pilldroid.models.Prescription; @@ -46,7 +46,7 @@ public class DrugDetailActivity extends AppCompatActivity { setSupportActionBar(toolbar); } - ImageButton fab = findViewById(R.id.fab); + FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(v -> { Log.d(TAG, "Click on save icon"); diff --git a/app/src/main/java/net/foucry/pilldroid/DrugDetailFragment.java b/app/src/main/java/net/foucry/pilldroid/DrugDetailFragment.java index a155349..566d8ec 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugDetailFragment.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugDetailFragment.java @@ -5,10 +5,11 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.fragment.app.Fragment; import com.google.android.material.appbar.MaterialToolbar; +import com.google.android.material.textfield.TextInputEditText; +import com.google.android.material.textview.MaterialTextView; import net.foucry.pilldroid.models.Prescription; /** @@ -72,34 +73,34 @@ public class DrugDetailFragment extends Fragment { if (prescription != null) { // Find each component of rootView nameView = detailView.findViewById(R.id.name_cell); - TextView nameLabel = nameView.findViewById(R.id.label); - TextView nameValue = nameView.findViewById(R.id.value); + MaterialTextView nameLabel = nameView.findViewById(R.id.label); + MaterialTextView nameValue = nameView.findViewById(R.id.value); nameLabel.setText(R.string.drug_name_label); nameValue.setText(prescription.getName()); presentationView = detailView.findViewById(R.id.presentation_cell); - TextView presentationLabel = presentationView.findViewById(R.id.label); - TextView presentationValue = presentationView.findViewById(R.id.value); + MaterialTextView presentationLabel = presentationView.findViewById(R.id.label); + MaterialTextView presentationValue = presentationView.findViewById(R.id.value); presentationLabel.setText(R.string.drug_presentation_label); presentationValue.setText(prescription.getPresentation()); adminModeView = detailView.findViewById(R.id.administration_cell); - TextView adminModeLabel = adminModeView.findViewById(R.id.label); - TextView adminModeValue = adminModeView.findViewById(R.id.value); + MaterialTextView adminModeLabel = adminModeView.findViewById(R.id.label); + MaterialTextView adminModeValue = adminModeView.findViewById(R.id.value); adminModeLabel.setText(R.string.drug_administrationMode_label); adminModeValue.setText(prescription.getAdministration_mode()); stockView = detailView.findViewById(R.id.stock_cell); - TextView stockLibelle = (stockView.findViewById(R.id.label)); - TextView stockValue = stockView.findViewById(R.id.value); + MaterialTextView stockLibelle = (stockView.findViewById(R.id.label)); + TextInputEditText stockValue = stockView.findViewById(R.id.value); stockLibelle.setText(R.string.drug_current_stock_label); stockValue.setText(Utils.fmt(prescription.getStock())); stockValue.setHint(R.string.drug_current_stock_label); stockValue.setSelectAllOnFocus(true); takeView = detailView.findViewById(R.id.take_cell); - TextView takeLabel = takeView.findViewById(R.id.label); - TextView takeValue = (takeView.findViewById(R.id.value)); + MaterialTextView takeLabel = takeView.findViewById(R.id.label); + TextInputEditText takeValue = (takeView.findViewById(R.id.value)); takeLabel.setText(R.string.drug_take_label); //takeValue.setText(Double.toString(prescription.getTake())); takeValue.setText(Utils.fmt(prescription.getTake())); @@ -107,8 +108,8 @@ public class DrugDetailFragment extends Fragment { takeValue.setSelectAllOnFocus(true); warningView = detailView.findViewById(R.id.warning_cell); - TextView warningLibelle = warningView.findViewById(R.id.label); - TextView warningValue = warningView.findViewById(R.id.value); + MaterialTextView warningLibelle = warningView.findViewById(R.id.label); + TextInputEditText warningValue = warningView.findViewById(R.id.value); warningLibelle.setText(R.string.drug_warningThreshold_label); //warningValue.setText(Integer.toString(prescription.getWarnThreshold())); warningValue.setText(Utils.fmt(prescription.getWarning())); @@ -116,8 +117,8 @@ public class DrugDetailFragment extends Fragment { warningValue.setSelectAllOnFocus(true); alertView = detailView.findViewById(R.id.alert_cell); - TextView alertLibelle = alertView.findViewById(R.id.label); - TextView alertValue = alertView.findViewById(R.id.value); + MaterialTextView alertLibelle = alertView.findViewById(R.id.label); + TextInputEditText alertValue = alertView.findViewById(R.id.value); alertLibelle.setText(R.string.drug_alertThreshold_label); //alertValue.setText(Integer.toString(prescription.getAlertThreshold())); alertValue.setText(Utils.fmt(prescription.getAlert())); diff --git a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java index c3d681e..c2b7833 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java @@ -378,21 +378,16 @@ public class DrugListActivity extends AppCompatActivity { } } }); - ok.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - dialog.cancel(); - Log.i("EditText Value",editText.getEditableText().toString()); - MedicinesDAO medicinesDAO = medicines.getMedicinesDAO(); - Medicine aMedicine = medicinesDAO.getMedicineByCIP13(cip13); - askToAddInDB(aMedicine); - } + ok.setOnClickListener(v -> { + dialog.cancel(); + Log.i("EditText Value",editText.getEditableText().toString()); + MedicinesDAO medicinesDAO = medicines.getMedicinesDAO(); + Medicine aMedicine = medicinesDAO.getMedicineByCIP13(cip13); + askToAddInDB(aMedicine); }); - cancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.cancel(); - Log.i(TAG, "dismiss dialog"); - } + cancel.setOnClickListener(v -> { + dialog.cancel(); + Log.i(TAG, "dismiss dialog"); }); dialog.show(); @@ -426,27 +421,21 @@ public class DrugListActivity extends AppCompatActivity { cpl.setEnabled(false); } icon.setImageResource(R.drawable.tickmark); - btn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - // TODO Auto-generated method stub - dlg.dismiss(); - finish(); - addDrugToList(Utils.medicine2prescription(aMedicine)); - } + btn.setOnClickListener(v -> { + // TODO Auto-generated method stub + dlg.dismiss(); + finish(); + addDrugToList(Utils.medicine2prescription(aMedicine)); }); } else { msgString = getString(R.string.msgNotFound); msg.setText(msgString); cpl.setText(""); icon.setImageResource(R.drawable.tickcross); - btn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - // TODO Auto-generated method stub - dlg.dismiss(); - finish(); - } + btn.setOnClickListener(v -> { + // TODO Auto-generated method stub + dlg.dismiss(); + finish(); }); } dlg.show(); @@ -524,13 +513,10 @@ public class DrugListActivity extends AppCompatActivity { } Snackbar.make(recyclerView, prescription.getName(), - Snackbar.LENGTH_LONG).setAction(R.string.Undo, new View.OnClickListener() { - @Override - public void onClick(View v) { - prescriptionList.add(position, prescription); - mAdapter.notifyItemInserted(position); - } - }).show(); + Snackbar.LENGTH_LONG).setAction(R.string.Undo, v -> { + prescriptionList.add(position, prescription); + mAdapter.notifyItemInserted(position); + }).show(); } @Override @@ -657,17 +643,14 @@ public class DrugListActivity extends AppCompatActivity { holder.mView.setBackgroundResource(R.drawable.gradient_bg); holder.mIconView.setImageResource(R.drawable.ic_suspended_pill); - holder.mView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Prescription aPrescription = mValues.get(position); - Context context = v.getContext(); - Intent intent = new Intent(context, DrugDetailActivity.class); - intent.putExtra("prescription", aPrescription); - startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); - overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); + holder.mView.setOnClickListener(v -> { + Prescription aPrescription = mValues.get(position); + Context context = v.getContext(); + Intent intent = new Intent(context, DrugDetailActivity.class); + intent.putExtra("prescription", aPrescription); + startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); + overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); - } }); } else { int remainingStock = (int) Math.floor(mValues.get(position).getStock() / mValues.get(position).getTake()); @@ -683,16 +666,13 @@ public class DrugListActivity extends AppCompatActivity { holder.mIconView.setImageResource(R.drawable.ok_stock_vect); } - holder.mView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Prescription prescription = mValues.get(position); - Context context = v.getContext(); - Intent intent = new Intent(context, DrugDetailActivity.class); - intent.putExtra("prescription", prescription); - startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); - overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); - } + holder.mView.setOnClickListener(v -> { + Prescription prescription = mValues.get(position); + Context context = v.getContext(); + Intent intent = new Intent(context, DrugDetailActivity.class); + intent.putExtra("prescription", prescription); + startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); + overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); }); } } diff --git a/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java b/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java index 0f24363..1dad17e 100644 --- a/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java @@ -13,23 +13,23 @@ import android.view.Window; import android.view.WindowInsets; import android.view.WindowInsetsController; import android.view.WindowManager; -import android.widget.Button; -import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; +import com.google.android.material.button.MaterialButton; +import com.google.android.material.imageview.ShapeableImageView; +import com.google.android.material.textview.MaterialTextView; public class WelcomeActivity extends AppCompatActivity { private ViewPager viewPager; private LinearLayout dotsLayout; private int[] layouts; - private Button btnSkip, btnNext; + private MaterialButton btnSkip, btnNext; // viewpager change listener final ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() { @@ -141,12 +141,12 @@ public class WelcomeActivity extends AppCompatActivity { dlg.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dlg.setContentView(R.layout.custom_dialog_layout_one_button); dlg.setCancelable(false); - TextView msg = dlg.findViewById(R.id.msg); + MaterialTextView msg = dlg.findViewById(R.id.msg); String msgString; - TextView cpl = dlg.findViewById(R.id.cpl); + MaterialTextView cpl = dlg.findViewById(R.id.cpl); String cplString = ""; - ImageView icon = dlg.findViewById(R.id.image); - Button btn = dlg.findViewById(R.id.txtClose); + ShapeableImageView icon = dlg.findViewById(R.id.image); + MaterialButton btn = dlg.findViewById(R.id.txtClose); dlg.show(); msgString = getString(R.string.understood); @@ -164,11 +164,11 @@ public class WelcomeActivity extends AppCompatActivity { } private void addBottomDots(int currentPage) { - TextView[] dots = new TextView[layouts.length]; + MaterialTextView[] dots = new MaterialTextView[layouts.length]; dotsLayout.removeAllViews(); for (int i = 0; i < dots.length; i++) { - dots[i] = new TextView(this); + dots[i] = new MaterialTextView(this); dots[i].setText("∙"); dots[i].setTextSize(65); dots[i].setTextColor(ContextCompat.getColor(this, R.color.dot_dark)); diff --git a/app/src/main/res/drawable/arrow_back.xml b/app/src/main/res/drawable/arrow_back.xml new file mode 100644 index 0000000..0e2e863 --- /dev/null +++ b/app/src/main/res/drawable/arrow_back.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/layout/about.xml b/app/src/main/res/layout/about.xml index 51b7569..4087f6b 100644 --- a/app/src/main/res/layout/about.xml +++ b/app/src/main/res/layout/about.xml @@ -1,11 +1,22 @@ - + + + - -