Add Rackup/Restore framework

This commit is contained in:
jacques 2024-06-11 20:44:24 +02:00
parent a593758fe5
commit 95159673d5
2 changed files with 14 additions and 44 deletions

View file

@ -116,6 +116,7 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.journeyapps:zxing-android-embedded:4.3.0' implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
implementation 'androidx.core:core:1.12.0' implementation 'androidx.core:core:1.12.0'
implementation 'de.raphaelebner:roomdatabasebackup:1.0.1'
//coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.0' //coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.0'
} }

View file

@ -61,6 +61,8 @@ 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
@ -76,6 +78,8 @@ public class DrugListActivity extends AppCompatActivity {
public final String BARCODE_CONTENT = "Barcode Content"; public final String BARCODE_CONTENT = "Barcode Content";
// Used for dev and debug // Used for dev and debug
final Boolean DEMO = false; final Boolean DEMO = false;
final private boolean enableLog = true;
final private boolean encryptBackup = true;
public PrescriptionDatabase prescriptions; public PrescriptionDatabase prescriptions;
public MedicineDatabase medicines; public MedicineDatabase medicines;
private ActivityResultLauncher<ScanOptions> mBarcodeScannerLauncher; private ActivityResultLauncher<ScanOptions> mBarcodeScannerLauncher;
@ -303,44 +307,11 @@ 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.export_prescription) { //backupPrescriptions();
final Dialog dlg = new Dialog(this); // TODO: a changer ainsi que le menu.
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
Objects.requireNonNull(dlg.getWindow()).setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dlg.setContentView(R.layout.custom_dialog_layout_one_button);
dlg.setCancelable(false);
TextView msg = dlg.findViewById(R.id.msg);
msg.setText("Demande de Backup");
TextView cpl = dlg.findViewById(R.id.cpl);
ImageView icon = dlg.findViewById(R.id.image);
Button btn = dlg.findViewById(R.id.txtClose);
btn.setText(R.string.button_ok);
btn.setOnClickListener(v -> {
dlg.dismiss();
finish();
});
dlg.show();
} else if (id == R.id.import_prescription) { } else if (id == R.id.import_prescription) {
final Dialog dlg = new Dialog(this); //restorePrescriptions();
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
Objects.requireNonNull(dlg.getWindow()).setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dlg.setContentView(R.layout.custom_dialog_layout_one_button);
dlg.setCancelable(false);
TextView msg = dlg.findViewById(R.id.msg);
msg.setText("Demande de Restauration");
TextView cpl = dlg.findViewById(R.id.cpl);
String cplString;
ImageView icon = dlg.findViewById(R.id.image);
Button btn = dlg.findViewById(R.id.txtClose);
btn.setText(R.string.button_ok);
btn.setOnClickListener(v -> {
dlg.dismiss();
finish();
});
dlg.show();
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -392,8 +363,6 @@ public class DrugListActivity extends AppCompatActivity {
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.
ok.setText(R.string.button_ok); ok.setText(R.string.button_ok);
cancel.setText(R.string.button_cancel); cancel.setText(R.string.button_cancel);
editText.addTextChangedListener(new TextWatcher() { editText.addTextChangedListener(new TextWatcher() {