Bugfix/gui improvment (#57)

* Change some options in order to make compilation/run in avd work

* Change layout for signedNumber

* Change button style (remove style statement).

* Change according to AndroidStudio. Change button  behaviors in EditCIP13.

---------

Co-authored-by: jacques <jacques+commit@foucry.net>
This commit is contained in:
Jacques Foucry 2024-05-17 19:39:28 +02:00 committed by GitHub
parent 2ff8ff9e53
commit 0a8bc41f61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 72 additions and 19 deletions

View file

@ -123,13 +123,14 @@ public class DrugDetailActivity extends AppCompatActivity {
String takeValue = takeTextView.getText().toString();
alertView = findViewById(R.id.alert_cell);
alertView.setContentDescription("R.string.Drug_warningThreshold_label");
TextView alertTextView = alertView.findViewById(R.id.value);
String alertValue = alertTextView.getText().toString();
warningView = findViewById(R.id.warning_cell);
warningView.setContentDescription("R.string.drug_alertThreshold_label");
TextView warningTextView = warningView.findViewById(R.id.value);
String warningValue = warningTextView.getText().toString();
newPrescription.setStock(Float.parseFloat(stockValue));
newPrescription.setTake(Float.parseFloat(takeValue));
newPrescription.setWarning(Integer.parseInt(warningValue));

View file

@ -60,6 +60,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
/**
* An activity representing a list of Drugs is activity
@ -225,6 +226,7 @@ public class DrugListActivity extends AppCompatActivity {
Log.d(TAG, "Missing camera permission");
Toast.makeText(this, R.string.missing_camera_permission, Toast.LENGTH_LONG).show();
} else {
assert bundle != null;
Log.d(TAG, "bundle == " + bundle.getInt("returnCode"));
int returnCode = bundle.getInt("returnCode");
int resultCode = bundle.getInt("resultCode");
@ -248,13 +250,13 @@ public class DrugListActivity extends AppCompatActivity {
}
String cip13;
switch (bundle.getString(BARCODE_FORMAT_NAME)) {
switch (Objects.requireNonNull(bundle.getString(BARCODE_FORMAT_NAME))) {
case "CODE_128":
case "EAN_13": //CODE_128 || EAN 13
cip13 = bundle.getString(BARCODE_CONTENT);
break;
case "DATA_MATRIX":
cip13 = bundle.getString(BARCODE_CONTENT).substring(4, 17);
cip13 = Objects.requireNonNull(bundle.getString(BARCODE_CONTENT)).substring(4, 17);
break;
default:
scanNotOK();
@ -340,7 +342,7 @@ public class DrugListActivity extends AppCompatActivity {
protected void showInputDialog() {
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
Objects.requireNonNull(dialog.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
@ -349,9 +351,9 @@ public class DrugListActivity extends AppCompatActivity {
MaterialButton ok = dialog.findViewById(R.id.agreed);
MaterialButton cancel = dialog.findViewById(R.id.notagreed);
ok.setEnabled(false);
ok.setBackground(ContextCompat.getDrawable(this, R.drawable.rounded_btn_disabled));
//MaterialTextView title = dialog.findViewById(R.id.title);
final EditText editText= dialog.findViewById(R.id.editcip13);
ok.setBackground(Objects.requireNonNull(ContextCompat.getDrawable(this, R.drawable.rounded_btn_disabled)));
MaterialTextView title = dialog.findViewById(R.id.title);
final EditText editText = dialog.findViewById(R.id.editcip13);
String cip13 = String.valueOf(editText.getText());
// TODO change the color of ok button when the number of character is correct.
@ -373,7 +375,11 @@ public class DrugListActivity extends AppCompatActivity {
//alert.getButton(alert.BUTTON_POSITIVE).setEnabled(s.length() == 8);
if (s.length() == 8) {
ok.setEnabled(true);
ok.setBackground(ContextCompat.getDrawable(editText.getContext(), R.drawable.shadow_bg));
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)));
}
}
});
@ -401,7 +407,7 @@ public class DrugListActivity extends AppCompatActivity {
private void askToAddInDB(Medicine aMedicine) {
final Dialog dlg = new Dialog(this);
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
dlg.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Objects.requireNonNull(dlg.getWindow()).setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dlg.setContentView(R.layout.custom_dialog_layout_one_button);
dlg.setCancelable(true);
MaterialTextView msg = dlg.findViewById(R.id.msg);

View file

@ -41,14 +41,14 @@
<include
android:id="@+id/warning_cell"
layout="@layout/value_input"
layout="@layout/value_input_threshold"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- android:layout_marginTop="15sp" />-->
<include
android:id="@+id/alert_cell"
layout="@layout/value_input"
layout="@layout/value_input_threshold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />

View file

@ -20,7 +20,6 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/notagreed"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="28dp"
@ -32,7 +31,7 @@
android:paddingStart="25dp"
android:paddingEnd="25dp"
android:text="@string/button_cancel"
android:textColor="#212121"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -48,7 +47,6 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/agreed"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="28dp"
@ -59,7 +57,7 @@
android:paddingStart="25dp"
android:paddingEnd="25dp"
android:text="@string/button_ok"
android:textColor="#212121"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="@+id/notagreed"
app:layout_constraintEnd_toEndOf="parent"
@ -99,11 +97,11 @@
<com.google.android.material.textview.MaterialTextView
android:id="@+id/textView4"
android:layout_width="55dp"
android:layout_height="33dp"
android:layout_width="75dp"
android:layout_height="34dp"
android:text="340009"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/editcip13"
app:layout_constraintHorizontal_bias="0.525"

View file

@ -36,7 +36,6 @@
android:layout_height="wrap_content"
android:ems="10"
android:gravity="end|fill_vertical"
android:importantForAutofill="no"
android:inputType="numberDecimal"
android:labelFor="@id/value"

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="1">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/inputLayout"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_toStartOf="@id/inputLayout"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:paddingEnd="25dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#040404"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/inputLayout"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="end|fill_vertical"
android:importantForAutofill="no"
android:inputType="numberSigned"
android:labelFor="@id/value"
android:paddingStart="5dp"
android:paddingEnd="25dp"
android:textAlignment="gravity"
android:textColorHint="@color/grey"
tools:ignore="LabelFor" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>