diff --git a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java index 2ee27d4..0af1a4d 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java @@ -43,6 +43,7 @@ import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; import androidx.room.Room; +import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.snackbar.Snackbar; import com.google.zxing.client.android.BuildConfig; import com.google.zxing.client.android.Intents; @@ -61,8 +62,6 @@ import java.util.List; import java.util.Locale; import java.util.Objects; -; - /** * An activity representing a list of Drugs is activity * has different presentations for handset and tablet-size devices. On @@ -189,6 +188,9 @@ public class DrugListActivity extends AppCompatActivity { toolbar.setTitle(getTitle()); } + FloatingActionButton mFloatingActionButton = findViewById(R.id.fab); + mFloatingActionButton.setOnClickListener(v-> onButtonClick()); + if (DEMO) { PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO(); @@ -307,11 +309,9 @@ public class DrugListActivity extends AppCompatActivity { startActivity(new Intent(this, WelcomeActivity.class)); return true; - } else if (id == R.id.export_prescription) { + } else if (id == R.id.ImportExport) { //backupPrescriptions(); // TODO: a changer ainsi que le menu. - } else if (id == R.id.import_prescription) { - //restorePrescriptions(); } return super.onOptionsItemSelected(item); } @@ -327,7 +327,7 @@ public class DrugListActivity extends AppCompatActivity { } // Launch scan - public void onButtonClick(View v) { + public void onButtonClick() { Log.d(TAG, "add medication"); ScanOptions options = new ScanOptions(); options.setDesiredBarcodeFormats(ScanOptions.DATA_MATRIX, ScanOptions.CODE_128); @@ -377,7 +377,14 @@ public class DrugListActivity extends AppCompatActivity { @Override public void afterTextChanged(Editable s) { //alert.getButton(alert.BUTTON_POSITIVE).setEnabled(s.length() == 8); - ok.setEnabled(s.length() == 8); + if (s.length() == 8) { + ok.setEnabled(true); + ok.setBackground(Objects.requireNonNull(ContextCompat.getDrawable(editText.getContext(), R.drawable.rounded_btn))); + } + else { + ok.setEnabled(false); + ok.setBackground(Objects.requireNonNull(ContextCompat.getDrawable(editText.getContext(), R.drawable.rounded_btn_disabled))); + } } }); ok.setOnClickListener(v -> { diff --git a/app/src/main/res/layout/input_dialog.xml b/app/src/main/res/layout/input_dialog.xml index 3b642ba..396c578 100644 --- a/app/src/main/res/layout/input_dialog.xml +++ b/app/src/main/res/layout/input_dialog.xml @@ -20,7 +20,6 @@ - - - - - - - + \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 5d66ec2..4d832f6 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -74,7 +74,4 @@ Annuler Icône de poubelle Ajouter à votre liste de médicament - Backup - Export - Import diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d1a52b1..28a0042 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -76,7 +76,7 @@ Undo Trash icon add to your list of medicine - Backup - Export - Import + Import/Export + Import + Export