use new input_layout dialog

This commit is contained in:
jacques 2023-07-26 22:00:23 +02:00
parent 1558b0182a
commit 85154e36e0

View file

@ -7,6 +7,7 @@ import android.annotation.SuppressLint;
import android.app.Dialog;
import android.app.NotificationManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@ -344,7 +345,7 @@ public class DrugListActivity extends AppCompatActivity {
// final EditText editText = promptView.findViewById(R.id.edittext);
// setup a dialog window
final Dialog dlg = new Dialog(this);
/*final Dialog dlg = new Dialog(this);
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
dlg.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dlg.setContentView(R.layout.input_dialog);
@ -360,7 +361,7 @@ public class DrugListActivity extends AppCompatActivity {
prompt.setText(R.string.enter_cip_13_here);
ok.setEnabled(false);
String cip13 = "34009" + editText.getText().toString();
icon.setImageResource(R.drawable.pilldroid_icon);
//icon.setImageResource(R.drawable.pilldroid_icon);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -393,7 +394,59 @@ public class DrugListActivity extends AppCompatActivity {
dlg.dismiss();
finish();
}
});*/
final Dialog dialog = new Dialog(this);
Window window = dialog.getWindow();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
dialog.setContentView(R.layout.input_dialog);
Button ok = (Button) dialog.findViewById(R.id.agreed);
Button cancel = (Button) dialog.findViewById(R.id.notagreed);
ok.setEnabled(false);
//TextView title = (TextView ) dialog.findViewById(R.id.title);
final EditText editText=(EditText)dialog.findViewById(R.id.editcip13);
String cip13 = String.valueOf(editText.getText());
//title.setText(R.string.enter_cip_13);
//alert_title.setTextSize(20);
ok.setText(R.string.button_ok);
cancel.setText(R.string.button_cancel);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
//alert.getButton(alert.BUTTON_POSITIVE).setEnabled(s.length() == 8);
ok.setEnabled(s.length() == 8);
}
});
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);
}
});
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.cancel();
Log.i(TAG, "dismiss dialog");
}
});
dialog.show();
}
/**