mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
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:
parent
2ff8ff9e53
commit
0a8bc41f61
6 changed files with 72 additions and 19 deletions
|
@ -123,13 +123,14 @@ public class DrugDetailActivity extends AppCompatActivity {
|
||||||
String takeValue = takeTextView.getText().toString();
|
String takeValue = takeTextView.getText().toString();
|
||||||
|
|
||||||
alertView = findViewById(R.id.alert_cell);
|
alertView = findViewById(R.id.alert_cell);
|
||||||
|
alertView.setContentDescription("R.string.Drug_warningThreshold_label");
|
||||||
TextView alertTextView = alertView.findViewById(R.id.value);
|
TextView alertTextView = alertView.findViewById(R.id.value);
|
||||||
String alertValue = alertTextView.getText().toString();
|
String alertValue = alertTextView.getText().toString();
|
||||||
|
|
||||||
warningView = findViewById(R.id.warning_cell);
|
warningView = findViewById(R.id.warning_cell);
|
||||||
|
warningView.setContentDescription("R.string.drug_alertThreshold_label");
|
||||||
TextView warningTextView = warningView.findViewById(R.id.value);
|
TextView warningTextView = warningView.findViewById(R.id.value);
|
||||||
String warningValue = warningTextView.getText().toString();
|
String warningValue = warningTextView.getText().toString();
|
||||||
|
|
||||||
newPrescription.setStock(Float.parseFloat(stockValue));
|
newPrescription.setStock(Float.parseFloat(stockValue));
|
||||||
newPrescription.setTake(Float.parseFloat(takeValue));
|
newPrescription.setTake(Float.parseFloat(takeValue));
|
||||||
newPrescription.setWarning(Integer.parseInt(warningValue));
|
newPrescription.setWarning(Integer.parseInt(warningValue));
|
||||||
|
|
|
@ -60,6 +60,7 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An activity representing a list of Drugs is activity
|
* An activity representing a list of Drugs is activity
|
||||||
|
@ -225,6 +226,7 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
Log.d(TAG, "Missing camera permission");
|
Log.d(TAG, "Missing camera permission");
|
||||||
Toast.makeText(this, R.string.missing_camera_permission, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.missing_camera_permission, Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
|
assert bundle != null;
|
||||||
Log.d(TAG, "bundle == " + bundle.getInt("returnCode"));
|
Log.d(TAG, "bundle == " + bundle.getInt("returnCode"));
|
||||||
int returnCode = bundle.getInt("returnCode");
|
int returnCode = bundle.getInt("returnCode");
|
||||||
int resultCode = bundle.getInt("resultCode");
|
int resultCode = bundle.getInt("resultCode");
|
||||||
|
@ -248,13 +250,13 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
String cip13;
|
String cip13;
|
||||||
switch (bundle.getString(BARCODE_FORMAT_NAME)) {
|
switch (Objects.requireNonNull(bundle.getString(BARCODE_FORMAT_NAME))) {
|
||||||
case "CODE_128":
|
case "CODE_128":
|
||||||
case "EAN_13": //CODE_128 || EAN 13
|
case "EAN_13": //CODE_128 || EAN 13
|
||||||
cip13 = bundle.getString(BARCODE_CONTENT);
|
cip13 = bundle.getString(BARCODE_CONTENT);
|
||||||
break;
|
break;
|
||||||
case "DATA_MATRIX":
|
case "DATA_MATRIX":
|
||||||
cip13 = bundle.getString(BARCODE_CONTENT).substring(4, 17);
|
cip13 = Objects.requireNonNull(bundle.getString(BARCODE_CONTENT)).substring(4, 17);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
scanNotOK();
|
scanNotOK();
|
||||||
|
@ -340,7 +342,7 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
protected void showInputDialog() {
|
protected void showInputDialog() {
|
||||||
final Dialog dialog = new Dialog(this);
|
final Dialog dialog = new Dialog(this);
|
||||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
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.setCancelable(true);
|
||||||
dialog.setCanceledOnTouchOutside(true);
|
dialog.setCanceledOnTouchOutside(true);
|
||||||
|
@ -349,9 +351,9 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
MaterialButton ok = dialog.findViewById(R.id.agreed);
|
MaterialButton ok = dialog.findViewById(R.id.agreed);
|
||||||
MaterialButton cancel = dialog.findViewById(R.id.notagreed);
|
MaterialButton cancel = dialog.findViewById(R.id.notagreed);
|
||||||
ok.setEnabled(false);
|
ok.setEnabled(false);
|
||||||
ok.setBackground(ContextCompat.getDrawable(this, R.drawable.rounded_btn_disabled));
|
ok.setBackground(Objects.requireNonNull(ContextCompat.getDrawable(this, R.drawable.rounded_btn_disabled)));
|
||||||
//MaterialTextView title = dialog.findViewById(R.id.title);
|
MaterialTextView title = dialog.findViewById(R.id.title);
|
||||||
final EditText editText= dialog.findViewById(R.id.editcip13);
|
final EditText editText = dialog.findViewById(R.id.editcip13);
|
||||||
String cip13 = String.valueOf(editText.getText());
|
String cip13 = String.valueOf(editText.getText());
|
||||||
|
|
||||||
// TODO change the color of ok button when the number of character is correct.
|
// 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);
|
//alert.getButton(alert.BUTTON_POSITIVE).setEnabled(s.length() == 8);
|
||||||
if (s.length() == 8) {
|
if (s.length() == 8) {
|
||||||
ok.setEnabled(true);
|
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) {
|
private void askToAddInDB(Medicine aMedicine) {
|
||||||
final Dialog dlg = new Dialog(this);
|
final Dialog dlg = new Dialog(this);
|
||||||
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
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.setContentView(R.layout.custom_dialog_layout_one_button);
|
||||||
dlg.setCancelable(true);
|
dlg.setCancelable(true);
|
||||||
MaterialTextView msg = dlg.findViewById(R.id.msg);
|
MaterialTextView msg = dlg.findViewById(R.id.msg);
|
||||||
|
|
|
@ -41,14 +41,14 @@
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/warning_cell"
|
android:id="@+id/warning_cell"
|
||||||
layout="@layout/value_input"
|
layout="@layout/value_input_threshold"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<!-- android:layout_marginTop="15sp" />-->
|
<!-- android:layout_marginTop="15sp" />-->
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/alert_cell"
|
android:id="@+id/alert_cell"
|
||||||
layout="@layout/value_input"
|
layout="@layout/value_input_threshold"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal" />
|
android:layout_gravity="center_horizontal" />
|
||||||
|
|
|
@ -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,7 +47,6 @@
|
||||||
|
|
||||||
<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="28dp"
|
||||||
|
@ -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"
|
||||||
|
@ -99,11 +97,11 @@
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/textView4"
|
android:id="@+id/textView4"
|
||||||
android:layout_width="55dp"
|
android:layout_width="75dp"
|
||||||
android:layout_height="33dp"
|
android:layout_height="34dp"
|
||||||
android:text="340009"
|
android:text="340009"
|
||||||
android:textAlignment="textEnd"
|
android:textAlignment="textEnd"
|
||||||
android:textSize="16sp"
|
android:textSize="20sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/editcip13"
|
app:layout_constraintEnd_toStartOf="@+id/editcip13"
|
||||||
app:layout_constraintHorizontal_bias="0.525"
|
app:layout_constraintHorizontal_bias="0.525"
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:gravity="end|fill_vertical"
|
android:gravity="end|fill_vertical"
|
||||||
|
|
||||||
android:importantForAutofill="no"
|
android:importantForAutofill="no"
|
||||||
android:inputType="numberDecimal"
|
android:inputType="numberDecimal"
|
||||||
android:labelFor="@id/value"
|
android:labelFor="@id/value"
|
||||||
|
|
49
app/src/main/res/layout/value_input_threshold.xml
Normal file
49
app/src/main/res/layout/value_input_threshold.xml
Normal 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>
|
Loading…
Reference in a new issue