Fix some regression in input_dialog.xml, DrugListActivity.java

This commit is contained in:
jacques 2024-07-05 20:35:22 +02:00
parent 495ce3be66
commit 707f4a7805
5 changed files with 22 additions and 27 deletions

View file

@ -43,6 +43,7 @@ import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.room.Room; import androidx.room.Room;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
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.BuildConfig;
import com.google.zxing.client.android.Intents; import com.google.zxing.client.android.Intents;
@ -61,8 +62,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Objects; import java.util.Objects;
;
/** /**
* 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
@ -189,6 +188,9 @@ public class DrugListActivity extends AppCompatActivity {
toolbar.setTitle(getTitle()); toolbar.setTitle(getTitle());
} }
FloatingActionButton mFloatingActionButton = findViewById(R.id.fab);
mFloatingActionButton.setOnClickListener(v-> onButtonClick());
if (DEMO) { if (DEMO) {
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO(); PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
@ -307,11 +309,9 @@ public class DrugListActivity extends AppCompatActivity {
startActivity(new Intent(this, WelcomeActivity.class)); startActivity(new Intent(this, WelcomeActivity.class));
return true; return true;
} else if (id == R.id.export_prescription) { } else if (id == R.id.ImportExport) {
//backupPrescriptions(); //backupPrescriptions();
// TODO: a changer ainsi que le menu. // TODO: a changer ainsi que le menu.
} else if (id == R.id.import_prescription) {
//restorePrescriptions();
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -327,7 +327,7 @@ public class DrugListActivity extends AppCompatActivity {
} }
// Launch scan // Launch scan
public void onButtonClick(View v) { public void onButtonClick() {
Log.d(TAG, "add medication"); Log.d(TAG, "add medication");
ScanOptions options = new ScanOptions(); ScanOptions options = new ScanOptions();
options.setDesiredBarcodeFormats(ScanOptions.DATA_MATRIX, ScanOptions.CODE_128); options.setDesiredBarcodeFormats(ScanOptions.DATA_MATRIX, ScanOptions.CODE_128);
@ -377,7 +377,14 @@ public class DrugListActivity extends AppCompatActivity {
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
//alert.getButton(alert.BUTTON_POSITIVE).setEnabled(s.length() == 8); //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 -> { ok.setOnClickListener(v -> {

View file

@ -20,7 +20,6 @@
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/notagreed" android:id="@+id/notagreed"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="28dp" android:layout_marginStart="28dp"
@ -32,7 +31,7 @@
android:paddingStart="25dp" android:paddingStart="25dp"
android:paddingEnd="25dp" android:paddingEnd="25dp"
android:text="@string/button_cancel" android:text="@string/button_cancel"
android:textColor="#212121" android:textColor="@color/white"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -48,10 +47,9 @@
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/agreed" android:id="@+id/agreed"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="28dp" android:layout_marginEnd="16dp"
android:background="@drawable/rounded_btn" android:background="@drawable/rounded_btn"
android:gravity="center" android:gravity="center"
android:maxLines="1" android:maxLines="1"
@ -59,7 +57,7 @@
android:paddingStart="25dp" android:paddingStart="25dp"
android:paddingEnd="25dp" android:paddingEnd="25dp"
android:text="@string/button_ok" android:text="@string/button_ok"
android:textColor="#212121" android:textColor="@color/white"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="@+id/notagreed" app:layout_constraintBottom_toBottomOf="@+id/notagreed"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"

View file

@ -2,15 +2,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/about" <item android:id="@+id/about"
android:title="@string/about"/> android:title="@string/about"/>
<item android:title="@string/backup"> <item android:id="@+id/ImportExport"
<menu> android:title="@string/import_export"/>
<item android:id="@+id/export_prescription"
android:title="@string/export_prescriptions"/>
<item android:id="@+id/import_prescription"
android:title="@string/import_prescriptions"/>
</menu>
</item>
<item android:id="@+id/help" <item android:id="@+id/help"
android:title="@string/help"/> android:title="@string/help"/>
</menu> </menu>

View file

@ -74,7 +74,4 @@
<string name="Undo">Annuler</string> <string name="Undo">Annuler</string>
<string name="trash_icon">Icône de poubelle</string> <string name="trash_icon">Icône de poubelle</string>
<string name="addInList">Ajouter à votre liste de médicament</string> <string name="addInList">Ajouter à votre liste de médicament</string>
<string name="backup">Backup</string>
<string name="export_prescriptions">Export</string>
<string name="import_prescriptions">Import</string>
</resources> </resources>

View file

@ -76,7 +76,7 @@
<string name="Undo">Undo</string> <string name="Undo">Undo</string>
<string name="trash_icon">Trash icon</string> <string name="trash_icon">Trash icon</string>
<string name="addInList">add to your list of medicine</string> <string name="addInList">add to your list of medicine</string>
<string name="backup">Backup</string> <string name="import_export" translatable="false">Import/Export</string>
<string name="export_prescriptions">Export</string> <string name="import_prescriptions" translatable="false">Import</string>
<string name="import_prescriptions">Import</string> <string name="export_prescriptions" translatable="false">Export</string>
</resources> </resources>