From 992a09cb127e474f6da2c3ec71c6115fa8b99b71 Mon Sep 17 00:00:00 2001 From: kroko Date: Tue, 30 Apr 2024 09:57:33 +0200 Subject: [PATCH] remove OEGD, change support/delete --- .idea/misc.xml | 4 + app/src/main/AndroidManifest.xml | 18 - .../labor_stein/befund/EditOEGDActivity.java | 457 ----------- .../labor_stein/befund/NewOEGDActivity.java | 354 --------- .../de/labor_stein/befund/OEGDActivity.java | 717 ------------------ .../main/res/layout/activity_edit_oegd.xml | 387 ---------- app/src/main/res/layout/activity_new_oegd.xml | 387 ---------- app/src/main/res/layout/activity_oegd.xml | 149 ---- .../main/res/layout/fragment_oegd_code.xml | 28 - .../main/res/layout/popup_oegd_options.xml | 152 ---- 10 files changed, 4 insertions(+), 2649 deletions(-) delete mode 100644 app/src/main/java/de/labor_stein/befund/EditOEGDActivity.java delete mode 100644 app/src/main/java/de/labor_stein/befund/NewOEGDActivity.java delete mode 100644 app/src/main/java/de/labor_stein/befund/OEGDActivity.java delete mode 100644 app/src/main/res/layout/activity_edit_oegd.xml delete mode 100644 app/src/main/res/layout/activity_new_oegd.xml delete mode 100644 app/src/main/res/layout/activity_oegd.xml delete mode 100644 app/src/main/res/layout/fragment_oegd_code.xml delete mode 100644 app/src/main/res/layout/popup_oegd_options.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index a602d81..19258ea 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -26,7 +26,11 @@ + + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d5dbf05..7021365 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -58,24 +58,6 @@ android:exported="true" android:label="@string/app_name" android:theme="@style/Theme.Befund.NoActionBar"> - - - { this.EditOEGDActivity_btnSave_Click(); }); - } - - EditOEGDActivity_txtTitle = findViewById(R.id.EditOEGDActivity_txtTitle); - EditOEGDActivity_txtFirstname = findViewById(R.id.EditOEGDActivity_txtFirstname); - EditOEGDActivity_txtLastname = findViewById(R.id.EditOEGDActivity_txtLastname); - EditOEGDActivity_txtAdditionLastname = findViewById(R.id.EditOEGDActivity_txtAdditionLastname); - EditOEGDActivity_txtPrefix = findViewById(R.id.EditOEGDActivity_txtPrefix); - EditOEGDActivity_txtGenders = findViewById(R.id.EditOEGDActivity_txtGenders); - EditOEGDActivity_txtBirthday = findViewById(R.id.EditOEGDActivity_txtBirthday); - EditOEGDActivity_txtStreet = findViewById(R.id.EditOEGDActivity_txtStreet); - EditOEGDActivity_txtZIP = findViewById(R.id.EditOEGDActivity_txtZIP); - EditOEGDActivity_txtCity = findViewById(R.id.EditOEGDActivity_txtCity); - EditOEGDActivity_txtTelefon = findViewById(R.id.EditOEGDActivity_txtTelefon); - EditOEGDActivity_Status = findViewById(R.id.EditOEGDActivity_Status); - - ArrayAdapter aa = new ArrayAdapter(this, android.R.layout.simple_spinner_item, this.Genders); - aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - EditOEGDActivity_txtGenders.setAdapter(aa); - - /** DatePicker **/ - BirthdayPicker = new DatePickerDialog(this, R.style.MySpinnerDatePickerStyle); - BirthdayPicker.getDatePicker().setMaxDate(new Date().getTime()); - BirthdayPicker.setOnDateSetListener(new DatePickerDialog.OnDateSetListener() - { - @Override - public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) - { - Date selectedDate = DateHelper.getDateFromDatePicket(BirthdayPicker.getDatePicker()); - - if(selectedDate != null) - { - SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy"); - EditOEGDActivity_txtBirthday.setText(dateFormat.format(selectedDate)); - } - } - }); - - /** Disable directly key insert in the birthday field(it should be set by DatePicker for well formed value) **/ - EditOEGDActivity_txtBirthday.setOnKeyListener((View v, int keyCode, KeyEvent event) -> { return true; }); - - /** Show/Hide DatePicker **/ - EditOEGDActivity_txtBirthday.setOnFocusChangeListener((View v, boolean hasFocus) -> { if(hasFocus) { BirthdayPicker.show(); } }); - EditOEGDActivity_txtBirthday.setOnTouchListener((View v, MotionEvent event) -> { BirthdayPicker.show(); return true; }); - - /** Set the values to the fields **/ - if(this.CurrentOEGD != null && this.CurrentOEGD.OEGD != null) - { - if(this.CurrentOEGD.OEGD.title != null && !this.CurrentOEGD.OEGD.title.isEmpty()) - { - EditOEGDActivity_txtTitle.setText(this.CurrentOEGD.OEGD.title); - } - - EditOEGDActivity_txtFirstname.setText(this.CurrentOEGD.OEGD.first_name); - EditOEGDActivity_txtLastname.setText(this.CurrentOEGD.OEGD.last_name); - - if(this.CurrentOEGD.OEGD.name_addition != null && !this.CurrentOEGD.OEGD.name_addition.isEmpty()) - { - EditOEGDActivity_txtAdditionLastname.setText(this.CurrentOEGD.OEGD.name_addition); - } - - if(this.CurrentOEGD.OEGD.prefix != null && !this.CurrentOEGD.OEGD.prefix.isEmpty()) - { - EditOEGDActivity_txtPrefix.setText(this.CurrentOEGD.OEGD.prefix); - } - - if(this.CurrentOEGD.OEGD.gender.toLowerCase().equals("m")) - { - EditOEGDActivity_txtGenders.setSelection(1); - } - else if(this.CurrentOEGD.OEGD.gender.toLowerCase().equals("w")) - { - EditOEGDActivity_txtGenders.setSelection(2); - } - else if(this.CurrentOEGD.OEGD.gender.toLowerCase().equals("d")) - { - EditOEGDActivity_txtGenders.setSelection(3); - } - else if(this.CurrentOEGD.OEGD.gender.toLowerCase().equals("x")) - { - EditOEGDActivity_txtGenders.setSelection(4); - } - - if(this.CurrentOEGD.OEGD.birthdate != null && !this.CurrentOEGD.OEGD.birthdate.isEmpty()) - { - Date birthday = this.CurrentOEGD.OEGD.GetBirthday(); - - if(birthday != null) - { - int year = DateHelper.GetFullYearFromDate(birthday); - int month = DateHelper.GetFullMonthFromDate(birthday); - int day = DateHelper.GetFullDayFromDate(birthday); - - BirthdayPicker.updateDate(year, month - 1, day); - EditOEGDActivity_txtBirthday.setText(this.CurrentOEGD.OEGD.GetFormatedBirthday()); - } - } - - EditOEGDActivity_txtStreet.setText(this.CurrentOEGD.OEGD.address.street_number); - EditOEGDActivity_txtCity.setText(this.CurrentOEGD.OEGD.address.city); - EditOEGDActivity_txtZIP.setText(this.CurrentOEGD.OEGD.address.zip_code); - - if(this.CurrentOEGD.OEGD.phone != null && !this.CurrentOEGD.OEGD.phone.isEmpty()) - { - EditOEGDActivity_txtTelefon.setText(this.CurrentOEGD.OEGD.phone); - } - } - } - - /** - * Initialize Layouts - */ - private void InitializeLayouts() - { - ActivityRootLayout = (CoordinatorLayout)findViewById(R.id.EditOEGDActivityRootLayout); - } - - /** - * Initializes Labels - */ - private void InitializeLabels() - { - lblEditOEGD = ActivityRootLayout.findViewById(R.id.lblEditOEGD); - EditOEGDActivitylblButtonBack = ActivityRootLayout.findViewById(R.id.EditOEGDActivitylblButtonBack); - } - - /** - * Initializes Buttons - */ - private void InitializeButtons() - { - OEGDButtonBack = ActivityRootLayout.findViewById(R.id.OEGDButtonBack); - OEGDButtonBack.setOnClickListener(v ->{ OEGDButtonBack_Click(); }); - } - - /** - * Go Back to OEGDActivity - */ - private void OEGDButtonBack_Click() - { - Intent intent = new Intent(this, OEGDActivity.class); - startActivity(intent); - overridePendingTransition(R.anim.side_in_left, R.anim.side_out_right); - } - - /** - * Save current OEGD - */ - private void EditOEGDActivity_btnSave_Click() - { - try - { - EditOEGDActivity_Status.setText(""); - - if(EditOEGDActivity_txtFirstname.getText() == null || EditOEGDActivity_txtFirstname.getText().toString().isEmpty()) - { - EditOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_FIRSTNAME")); - } - else if(EditOEGDActivity_txtLastname.getText() == null || EditOEGDActivity_txtLastname.getText().toString().isEmpty()) - { - EditOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_LASTNAME")); - } - else if(EditOEGDActivity_txtBirthday.getText() == null || EditOEGDActivity_txtBirthday.getText().toString().isEmpty()) - { - EditOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_BIRTHDAY")); - } - else if(EditOEGDActivity_txtGenders.getSelectedItemPosition() <= 0) - { - EditOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_GENDER")); - } - else if(EditOEGDActivity_txtStreet.getText() == null || EditOEGDActivity_txtStreet.getText().toString().isEmpty()) - { - EditOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_STREET")); - } - else if(EditOEGDActivity_txtZIP.getText() == null || EditOEGDActivity_txtZIP.getText().toString().isEmpty()) - { - EditOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_ZIP")); - } - else if(EditOEGDActivity_txtCity.getText() == null || EditOEGDActivity_txtCity.getText().toString().isEmpty()) - { - EditOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_CITY")); - } - else - { - OEGD oegd = new OEGD(); - oegd.first_name = EditOEGDActivity_txtFirstname.getText().toString(); - oegd.last_name = EditOEGDActivity_txtLastname.getText().toString(); - - Date selectedDate = DateHelper.getDateFromDatePicket(BirthdayPicker.getDatePicker()); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - oegd.birthdate = dateFormat.format(selectedDate); - - int genderIndex = (int)EditOEGDActivity_txtGenders.getSelectedItemId(); - String gender_full_name = Genders[genderIndex]; - - if(gender_full_name.equals(Lang.Get("LBL_GENDER_M"))) - { - oegd.gender = "M"; - } - else if(gender_full_name.equals(Lang.Get("LBL_GENDER_W"))) - { - oegd.gender = "W"; - } - else if(gender_full_name.equals(Lang.Get("LBL_GENDER_D"))) - { - oegd.gender = "D"; - } - else - { - oegd.gender = "X"; - } - - if(EditOEGDActivity_txtTitle.getText() != null && !EditOEGDActivity_txtTitle.getText().toString().isEmpty()) - { - oegd.title = EditOEGDActivity_txtTitle.getText().toString(); - } - - if(EditOEGDActivity_txtAdditionLastname.getText() != null && !EditOEGDActivity_txtAdditionLastname.getText().toString().isEmpty()) - { - oegd.name_addition = EditOEGDActivity_txtAdditionLastname.getText().toString(); - } - - if(EditOEGDActivity_txtPrefix.getText() != null && !EditOEGDActivity_txtPrefix.getText().toString().isEmpty()) - { - oegd.prefix = EditOEGDActivity_txtPrefix.getText().toString(); - } - - oegd.address = OEGD.Address.createInstance(); - oegd.address.zip_code = EditOEGDActivity_txtZIP.getText().toString(); - oegd.address.city = EditOEGDActivity_txtCity.getText().toString(); - oegd.address.street_number = EditOEGDActivity_txtStreet.getText().toString(); - oegd.address.country_code = "D"; - oegd.cwa_consent_flag = true; - - if(EditOEGDActivity_txtTelefon.getText() != null && !EditOEGDActivity_txtTelefon.getText().toString().isEmpty()) - { - oegd.phone = EditOEGDActivity_txtTelefon.getText().toString(); - } - - String json = new Gson().toJson(oegd); - - if(json != null) - { - String encrypted_content = AES.Encrypt(json, AES.GetKey(Session.DevicePassword)); - - if(encrypted_content != null) - { - if(System.WriteToStorage(this.CurrentOEGD.filename, encrypted_content.getBytes(StandardCharsets.UTF_8), this)) - { - GoToOEGDActivity(); - } - else - { - EditOEGDActivity_Status.setText(Lang.Get("ERROR_COULD_NOT_SAVE_OEGD")); - } - } - else - { - EditOEGDActivity_Status.setText(Lang.Get("ERROR_COULD_NOT_SAVE_OEGD")); - } - } - else - { - EditOEGDActivity_Status.setText(Lang.Get("ERROR_COULD_NOT_SAVE_OEGD")); - } - } - } - catch (Exception ex) - { - Log.Error(ex.getMessage(), "EditOEGDActivity", "EditOEGDActivity_btnCreate_Click"); - } - } - - /** - * Goes back to OEGDActivity - */ - private void GoToOEGDActivity() - { - Intent OEGDActivity = new Intent(this, OEGDActivity.class); - startActivity(OEGDActivity); - overridePendingTransition(R.anim.side_in_left, R.anim.side_out_right); - } -} \ No newline at end of file diff --git a/app/src/main/java/de/labor_stein/befund/NewOEGDActivity.java b/app/src/main/java/de/labor_stein/befund/NewOEGDActivity.java deleted file mode 100644 index 46da584..0000000 --- a/app/src/main/java/de/labor_stein/befund/NewOEGDActivity.java +++ /dev/null @@ -1,354 +0,0 @@ -// -// NewOEGDActivity.java -// Befund -// -// Created by Irakli Abetschkhrischwili on 02.07.22. -// Copyright © 2022 MVZ Dr. Stein und Kollegen. All rights reserved. - -package de.labor_stein.befund; - -import android.app.DatePickerDialog; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.View; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.CheckBox; -import android.widget.DatePicker; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.PopupWindow; -import android.widget.Spinner; -import android.widget.TextView; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.coordinatorlayout.widget.CoordinatorLayout; - -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.google.gson.Gson; - -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.UUID; - -import de.labor_stein.befund.Core.Helpers.DateHelper; -import de.labor_stein.befund.Core.Lang.Lang; -import de.labor_stein.befund.Core.Log; -import de.labor_stein.befund.Core.Models.OEGD; -import de.labor_stein.befund.Core.Models.Session; -import de.labor_stein.befund.Core.Security.AES; -import de.labor_stein.befund.Core.System; - -public class NewOEGDActivity extends AppCompatActivity -{ - /** NewOEGDActivityContext **/ - private Context MainContext; - - /** Layouts **/ - private CoordinatorLayout ActivityRootLayout; - - /** Controls **/ - private TextView lblNewOEGD; - private TextView NewOEGDActivitylblButtonBack; - private EditText NewOEGDActivity_txtTitle; - private EditText NewOEGDActivity_txtFirstname; - private EditText NewOEGDActivity_txtLastname; - private EditText NewOEGDActivity_txtAdditionLastname; - private EditText NewOEGDActivity_txtPrefix; - private Spinner NewOEGDActivity_txtGenders; - private EditText NewOEGDActivity_txtBirthday; - private DatePickerDialog BirthdayPicker; - private EditText NewOEGDActivity_txtStreet; - private EditText NewOEGDActivity_txtZIP; - private EditText NewOEGDActivity_txtCity; - private EditText NewOEGDActivity_txtTelefon; - - private Button NewOEGDActivity_btnCreate; - private TextView NewOEGDActivity_Status; - - /** Buttons **/ - private FloatingActionButton OEGDButtonBack; - - /** List items **/ - private String[] Genders = { Lang.Get("LBL_GENDER"), Lang.Get("LBL_GENDER_M"), Lang.Get("LBL_GENDER_W"), Lang.Get("LBL_GENDER_D"), Lang.Get("LBL_GENDER_X") }; - - @Override - protected void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_new_oegd); - - this.Initialize(); - } - - /** - * Initializes eIDActivity - */ - private void Initialize() - { - MainContext = this; - Log.Initialize(this); - - this.InitializeLayouts(); - this.InitializeLabels(); - this.InitializeButtons(); - this.InitializeControls(); - - this.InitializeLanguages(); - } - - /** - * Initializes Languages - */ - private void InitializeLanguages() - { - lblNewOEGD.setText(Lang.Get("LBL_NEW_OEGD")); - NewOEGDActivitylblButtonBack.setText(Lang.Get("BTN_BACK")); - - NewOEGDActivity_txtTitle.setHint(Lang.Get("LBL_TITLE")); - NewOEGDActivity_txtFirstname.setHint(Lang.Get("LBL_FIRSTNAME")); - NewOEGDActivity_txtLastname.setHint(Lang.Get("LBL_LASTNAME")); - NewOEGDActivity_txtAdditionLastname.setHint(Lang.Get("LBL_ADDITION_NAME")); - NewOEGDActivity_txtPrefix.setHint(Lang.Get("LBL_NAME_PREFIX")); - NewOEGDActivity_txtBirthday.setHint(Lang.Get("LBL_BIRTHDAY")); - NewOEGDActivity_txtStreet.setHint(Lang.Get("LBL_STREET")); - NewOEGDActivity_txtZIP.setHint(Lang.Get("LBL_ZIP")); - NewOEGDActivity_txtCity.setHint(Lang.Get("LBL_CITY")); - NewOEGDActivity_txtTelefon.setHint(Lang.Get("LBL_TELEFON")); - NewOEGDActivity_btnCreate.setText(Lang.Get("BTN_CREATE")); - } - - /** - * Initializes controls - */ - private void InitializeControls() - { - NewOEGDActivity_btnCreate = findViewById(R.id.NewOEGDActivity_btnCreate); - NewOEGDActivity_txtTitle = findViewById(R.id.NewOEGDActivity_txtTitle); - NewOEGDActivity_txtFirstname = findViewById(R.id.NewOEGDActivity_txtFirstname); - NewOEGDActivity_txtLastname = findViewById(R.id.NewOEGDActivity_txtLastname); - NewOEGDActivity_txtAdditionLastname = findViewById(R.id.NewOEGDActivity_txtAdditionLastname); - NewOEGDActivity_txtPrefix = findViewById(R.id.NewOEGDActivity_txtPrefix); - NewOEGDActivity_txtGenders = findViewById(R.id.NewOEGDActivity_txtGenders); - NewOEGDActivity_txtBirthday = findViewById(R.id.NewOEGDActivity_txtBirthday); - NewOEGDActivity_txtStreet = findViewById(R.id.NewOEGDActivity_txtStreet); - NewOEGDActivity_txtZIP = findViewById(R.id.NewOEGDActivity_txtZIP); - NewOEGDActivity_txtCity = findViewById(R.id.NewOEGDActivity_txtCity); - NewOEGDActivity_txtTelefon = findViewById(R.id.NewOEGDActivity_txtTelefon); - NewOEGDActivity_Status = findViewById(R.id.NewOEGDActivity_Status); - - ArrayAdapter aa = new ArrayAdapter(this, android.R.layout.simple_spinner_item, this.Genders); - aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - NewOEGDActivity_txtGenders.setAdapter(aa); - - /** DatePicker **/ - BirthdayPicker = new DatePickerDialog(this, R.style.MySpinnerDatePickerStyle); - BirthdayPicker.getDatePicker().setMaxDate(new Date().getTime()); - BirthdayPicker.setOnDateSetListener(new DatePickerDialog.OnDateSetListener() - { - @Override - public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) - { - Date selectedDate = DateHelper.getDateFromDatePicket(BirthdayPicker.getDatePicker()); - - if(selectedDate != null) - { - SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy"); - NewOEGDActivity_txtBirthday.setText(dateFormat.format(selectedDate)); - } - } - }); - - /** Disable directly key insert in the birthday field(it should be set by DatePicker for well formed value) **/ - NewOEGDActivity_txtBirthday.setOnKeyListener((View v, int keyCode, KeyEvent event) -> { return true; }); - - /** Show/Hide DatePicker **/ - NewOEGDActivity_txtBirthday.setOnFocusChangeListener((View v, boolean hasFocus) -> { if(hasFocus) { BirthdayPicker.show(); } }); - NewOEGDActivity_txtBirthday.setOnTouchListener((View v, MotionEvent event) -> { BirthdayPicker.show(); return true; }); - - NewOEGDActivity_btnCreate.setOnClickListener(v -> { this.NewOEGDActivity_btnCreate_Click(); }); - - //NewOEGDActivity_btnAcceptCWAPolicy.setOnClickListener((v) -> { PopupCWAPolicy.showAtLocation(ActivityRootLayout, Gravity.CENTER,0,0);}); - } - - /** - * Initialize Layouts - */ - private void InitializeLayouts() - { - ActivityRootLayout = (CoordinatorLayout)findViewById(R.id.NewOEGDActivityRootLayout); - } - - /** - * Initializes Labels - */ - private void InitializeLabels() - { - lblNewOEGD = ActivityRootLayout.findViewById(R.id.lblNewOEGD); - NewOEGDActivitylblButtonBack = ActivityRootLayout.findViewById(R.id.NewOEGDActivitylblButtonBack); - } - - /** - * Initializes Buttons - */ - private void InitializeButtons() - { - OEGDButtonBack = ActivityRootLayout.findViewById(R.id.OEGDButtonBack); - OEGDButtonBack.setOnClickListener(v ->{ OEGDButtonBack_Click(); }); - } - - /** - * Go Back to OEGDActivity - */ - private void OEGDButtonBack_Click() - { - Intent intent = new Intent(this, OEGDActivity.class); - startActivity(intent); - overridePendingTransition(R.anim.side_in_left, R.anim.side_out_right); - } - - /** - * Creates a new OEGD - */ - private void NewOEGDActivity_btnCreate_Click() - { - try - { - NewOEGDActivity_Status.setText(""); - - if(NewOEGDActivity_txtFirstname.getText() == null || NewOEGDActivity_txtFirstname.getText().toString().isEmpty()) - { - NewOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_FIRSTNAME")); - } - else if(NewOEGDActivity_txtLastname.getText() == null || NewOEGDActivity_txtLastname.getText().toString().isEmpty()) - { - NewOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_LASTNAME")); - } - else if(NewOEGDActivity_txtBirthday.getText() == null || NewOEGDActivity_txtBirthday.getText().toString().isEmpty()) - { - NewOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_BIRTHDAY")); - } - else if(NewOEGDActivity_txtGenders.getSelectedItemPosition() <= 0) - { - NewOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_GENDER")); - } - else if(NewOEGDActivity_txtStreet.getText() == null || NewOEGDActivity_txtStreet.getText().toString().isEmpty()) - { - NewOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_STREET")); - } - else if(NewOEGDActivity_txtZIP.getText() == null || NewOEGDActivity_txtZIP.getText().toString().isEmpty()) - { - NewOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_ZIP")); - } - else if(NewOEGDActivity_txtCity.getText() == null || NewOEGDActivity_txtCity.getText().toString().isEmpty()) - { - NewOEGDActivity_Status.setText(Lang.Get("ERROR_ENTER_CITY")); - } - else - { - OEGD oegd = new OEGD(); - oegd.first_name = NewOEGDActivity_txtFirstname.getText().toString(); - oegd.last_name = NewOEGDActivity_txtLastname.getText().toString(); - - Date selectedDate = DateHelper.getDateFromDatePicket(BirthdayPicker.getDatePicker()); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - oegd.birthdate = dateFormat.format(selectedDate); - - int genderIndex = (int)NewOEGDActivity_txtGenders.getSelectedItemId(); - String gender_full_name = Genders[genderIndex]; - - if(gender_full_name.equals(Lang.Get("LBL_GENDER_M"))) - { - oegd.gender = "M"; - } - else if(gender_full_name.equals(Lang.Get("LBL_GENDER_W"))) - { - oegd.gender = "W"; - } - else if(gender_full_name.equals(Lang.Get("LBL_GENDER_D"))) - { - oegd.gender = "D"; - } - else - { - oegd.gender = "X"; - } - - if(NewOEGDActivity_txtTitle.getText() != null && !NewOEGDActivity_txtTitle.getText().toString().isEmpty()) - { - oegd.title = NewOEGDActivity_txtTitle.getText().toString(); - } - - if(NewOEGDActivity_txtAdditionLastname.getText() != null && !NewOEGDActivity_txtAdditionLastname.getText().toString().isEmpty()) - { - oegd.name_addition = NewOEGDActivity_txtAdditionLastname.getText().toString(); - } - - if(NewOEGDActivity_txtPrefix.getText() != null && !NewOEGDActivity_txtPrefix.getText().toString().isEmpty()) - { - oegd.prefix = NewOEGDActivity_txtPrefix.getText().toString(); - } - - oegd.address = OEGD.Address.createInstance(); - oegd.address.zip_code = NewOEGDActivity_txtZIP.getText().toString(); - oegd.address.city = NewOEGDActivity_txtCity.getText().toString(); - oegd.address.street_number = NewOEGDActivity_txtStreet.getText().toString(); - oegd.address.country_code = "D"; - - if(NewOEGDActivity_txtTelefon.getText() != null && !NewOEGDActivity_txtTelefon.getText().toString().isEmpty()) - { - oegd.phone = NewOEGDActivity_txtTelefon.getText().toString(); - } - - String json = new Gson().toJson(oegd); - - if(json != null) - { - String encrypted_content = AES.Encrypt(json, AES.GetKey(Session.DevicePassword)); - - if(encrypted_content != null) - { - SimpleDateFormat dF = new SimpleDateFormat("yyyyMMdd_HH_mm_ss"); - String filename = dF.format(new Date()) + "_" + UUID.randomUUID().toString().replace("-", "") + ".oegd"; - - if(System.WriteToStorage(filename, encrypted_content.getBytes(StandardCharsets.UTF_8), this)) - { - GoToOEGDActivity(); - } - else - { - NewOEGDActivity_Status.setText(Lang.Get("ERROR_COULD_NOT_SAVE_OEGD")); - } - } - else - { - NewOEGDActivity_Status.setText(Lang.Get("ERROR_COULD_NOT_SAVE_OEGD")); - } - } - else - { - NewOEGDActivity_Status.setText(Lang.Get("ERROR_COULD_NOT_SAVE_OEGD")); - } - } - } - catch (Exception ex) - { - Log.Error(ex.getMessage(), "NewOEGDActivity", "NewOEGDActivity_btnCreate_Click"); - } - } - - /** - * Goes back to OEGDActivity - */ - private void GoToOEGDActivity() - { - Intent OEGDActivity = new Intent(this, OEGDActivity.class); - startActivity(OEGDActivity); - overridePendingTransition(R.anim.side_in_left, R.anim.side_out_right); - } -} \ No newline at end of file diff --git a/app/src/main/java/de/labor_stein/befund/OEGDActivity.java b/app/src/main/java/de/labor_stein/befund/OEGDActivity.java deleted file mode 100644 index 3a05fd2..0000000 --- a/app/src/main/java/de/labor_stein/befund/OEGDActivity.java +++ /dev/null @@ -1,717 +0,0 @@ -// -// OEGDActivity.java -// Befund -// -// Created by Irakli Abetschkhrischwili on 02.07.22. -// Copyright © 2022 MVZ Dr. Stein und Kollegen. All rights reserved. - -package de.labor_stein.befund; - -import android.content.Context; -import android.content.Intent; -import android.graphics.Bitmap; -import android.os.Bundle; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; -import android.view.animation.LinearInterpolator; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.PopupWindow; -import android.widget.ProgressBar; -import android.widget.TextView; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.coordinatorlayout.widget.CoordinatorLayout; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentPagerAdapter; -import androidx.fragment.app.FragmentStatePagerAdapter; -import androidx.viewpager.widget.PagerAdapter; -import androidx.viewpager.widget.ViewPager; - -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.google.gson.Gson; - -import java.io.File; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; - -import de.labor_stein.befund.Core.Helpers.ImageHelper; -import de.labor_stein.befund.Core.Https.Request; -import de.labor_stein.befund.Core.Lang.Lang; -import de.labor_stein.befund.Core.Log; -import de.labor_stein.befund.Core.Models.Database.Status; -import de.labor_stein.befund.Core.Models.Labor; -import de.labor_stein.befund.Core.Models.OEGD; -import de.labor_stein.befund.Core.Models.OEGDFile; -import de.labor_stein.befund.Core.Models.Request.EncryptedRequest; -import de.labor_stein.befund.Core.Models.Session; -import de.labor_stein.befund.Core.Security.AES; -import de.labor_stein.befund.Core.System; - -public class OEGDActivity extends AppCompatActivity -{ - /** OEGDActivityContext **/ - private Context MainContext; - - /** Layouts **/ - private CoordinatorLayout ActivityRootLayout; - - /** Controls **/ - private TextView lblOEGD; - private TextView lblOEGDButtonButtonBack; - private TextView lblNoOEGD; - private ProgressBar OEGDMainLoading; - - /** Buttons **/ - private FloatingActionButton OEGDButtonBack; - private Button bottomOEGDButtonMenuOpener; - - /** BEGIN POPUPS **/ - - /** BEGIN OptionsPopup **/ - private PopupWindow OEGDOptionsOptions; - private View OEGDOptionsOptions_Overlay; - private LinearLayout OEGDOptionsOptions_Popup; - private Button OEGDOptionsOptions_BtnAdd; - private LinearLayout OEGDOptionsEditView; - private Button OEGDOptionsOptions_BtnEdit; - private LinearLayout OEGDOptionsDeleteView; - private Button OEGDOptionsOptions_BtnDelete; - private Button OEGDOptionsOptions_BtnCancel; - /** END OptionsPopup **/ - - /** BEGIN ConfirmDeletePopup **/ - private PopupWindow ConfirmDeletePopup; - private View ConfirmDeletePopup_Overlay; - private LinearLayout ConfirmDeletePopup_Popup; - private TextView PopupConfirmDelete_text; - private Button ConfirmDeletePopup_BtnYES; - private Button ConfirmDeletePopup_BtnNO; - /** END ConfirmDeletePopup **/ - - /** END POPUPS **/ - - /** OEGDs **/ - private List OEGDFiles; - private OEGDFile CurrentOEGDFile = null; - - /** ViewPager **/ - private ViewPager Pager; - private PagerAdapter Adapter; - - @Override - protected void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_oegd); - - this.Initialize(); - } - - /** - * Initializes OEGDActivity - */ - private void Initialize() - { - MainContext = this; - Log.Initialize(this); - - this.InitializeLayouts(); - this.InitializeLabels(); - this.InitializeButtons(); - this.InitializeOptionsPopup(); - this.InitializeConfirmDeletePopup(); - this.InitializePager(); - this.InitializeLanguages(); - - this.loadOEGDs(); - } - - /** - * Initialize Layouts - */ - private void InitializeLayouts() - { - ActivityRootLayout = (CoordinatorLayout)findViewById(R.id.OEGDActivityRootLayout); - } - - /** - * Initializes Labels - */ - private void InitializeLabels() - { - lblOEGD = ActivityRootLayout.findViewById(R.id.lblOEGD); - lblOEGDButtonButtonBack = ActivityRootLayout.findViewById(R.id.lblOEGDButtonButtonBack); - lblNoOEGD = ActivityRootLayout.findViewById(R.id.lblNoOEGD); - OEGDMainLoading = ActivityRootLayout.findViewById(R.id.OEGDMainLoading); - OEGDMainLoading.setVisibility(View.GONE); - } - - /** - * Initializes Buttons - */ - private void InitializeButtons() - { - OEGDButtonBack = ActivityRootLayout.findViewById(R.id.OEGDButtonBack); - OEGDButtonBack.setOnClickListener(v ->{ OEGDButtonBack_Click(); }); - bottomOEGDButtonMenuOpener = ActivityRootLayout.findViewById(R.id.bottomOEGDButtonMenuOpener); - bottomOEGDButtonMenuOpener.setOnClickListener(v -> { this.OEGDOptionsOptions_Show(); }); - } - - /** - * Initializes ConfirmDelete Popup - */ - private void InitializeConfirmDeletePopup() - { - LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE); - ConfirmDeletePopup_Overlay = inflater.inflate(R.layout.popup_confirm_delete, null); - ConfirmDeletePopup_Popup = ConfirmDeletePopup_Overlay.findViewById(R.id.PopupConfirm_Popup); - PopupConfirmDelete_text = ConfirmDeletePopup_Overlay.findViewById(R.id.PopupConfirmDelete_text); - ConfirmDeletePopup_BtnYES = ConfirmDeletePopup_Overlay.findViewById(R.id.PopupPasswordConfirm_BtnYES); - ConfirmDeletePopup_BtnYES.setOnClickListener(v -> { this.ConfirmDeletePopup_BtnYES_Click(); }); - ConfirmDeletePopup_BtnNO = ConfirmDeletePopup_Overlay.findViewById(R.id.PopupConfirmDelete_BtnNO); - ConfirmDeletePopup_BtnNO.setOnClickListener(v -> { this.OConfirmDeletePopup_Hide(); }); - - /** Create popup window context **/ - ConfirmDeletePopup = new PopupWindow( - ConfirmDeletePopup_Overlay, - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT, - true - ); - } - - /** - * Initializes Options Popup - */ - private void InitializeOptionsPopup() - { - LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE); - OEGDOptionsOptions_Overlay = inflater.inflate(R.layout.popup_oegd_options, null); - OEGDOptionsOptions_Popup = OEGDOptionsOptions_Overlay.findViewById(R.id.OEGDOptions_Popup); - OEGDOptionsOptions_BtnAdd = OEGDOptionsOptions_Overlay.findViewById(R.id.OEGDOptions_BtnAdd); - OEGDOptionsOptions_BtnAdd.setOnClickListener(v -> { this.OEGDOptionsOptions_BtnAdd_Click(); }); - OEGDOptionsEditView = OEGDOptionsOptions_Overlay.findViewById(R.id.OEGDOptionsEditView); - OEGDOptionsOptions_BtnEdit = OEGDOptionsOptions_Overlay.findViewById(R.id.OEGDOptions_BtnEdit); - OEGDOptionsOptions_BtnEdit.setOnClickListener(v -> { this.OEGDOptionsOptions_BtnEdit_Click(); }); - OEGDOptionsDeleteView = OEGDOptionsOptions_Overlay.findViewById(R.id.OEGDOptionsDeleteView); - OEGDOptionsOptions_BtnDelete = OEGDOptionsOptions_Overlay.findViewById(R.id.OEGDOptions_BtnDelete); - OEGDOptionsOptions_BtnDelete.setOnClickListener(v -> { this.OEGDOptionsOptions_BtnDelete_Click(); }); - OEGDOptionsOptions_BtnCancel = OEGDOptionsOptions_Overlay.findViewById(R.id.OEGDOptions_BtnCancel); - OEGDOptionsOptions_BtnCancel.setOnClickListener(v -> { this.OEGDOptionsOptions_BtnCancel_Click(); }); - - /** Create popup window context **/ - OEGDOptionsOptions = new PopupWindow( - OEGDOptionsOptions_Overlay, - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT, - true - ); - } - - /** - * Initializes OEGD Pager - */ - private void InitializePager() - { - Pager = (ViewPager) findViewById(R.id.OEGDPager); - Adapter = new OEGDActivity.OEGDPagerAdapter(getSupportFragmentManager(), this.OEGDFiles, this); - Pager.setAdapter(Adapter); - - Pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() - { - @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) - { - CurrentOEGDFile = null; - OEGDOptionsEditView.setVisibility(View.GONE); - OEGDOptionsDeleteView.setVisibility(View.GONE); - - if(OEGDFiles != null && OEGDFiles.size() > 0 && position >= 0 && position < OEGDFiles.size()) - { - OEGDOptionsEditView.setVisibility(View.VISIBLE); - OEGDOptionsDeleteView.setVisibility(View.VISIBLE); - CurrentOEGDFile = OEGDFiles.get(position); - } - } - - @Override - public void onPageSelected(int position) {} - - @Override - public void onPageScrollStateChanged(int state) {} - }); - } - - /** - * Initializes Languages - */ - private void InitializeLanguages() - { - lblOEGD.setText(Lang.Get("LBL_OEGD")); - - lblNoOEGD.setText(Lang.Get("LBL_NO_OEGD")); - lblOEGDButtonButtonBack.setText(Lang.Get("BTN_BACK")); - OEGDOptionsOptions_BtnAdd.setText(Lang.Get("BTN_ADD")); - OEGDOptionsOptions_BtnEdit.setText(Lang.Get("BTN_EDIT")); - OEGDOptionsOptions_BtnDelete.setText(Lang.Get("BTN_DELETE")); - OEGDOptionsOptions_BtnCancel.setText(Lang.Get("BTN_CANCEL")); - ConfirmDeletePopup_BtnYES.setText(Lang.Get("BTN_YES")); - ConfirmDeletePopup_BtnNO.setText(Lang.Get("BTN_NO")); - } - - /** BEGIN EVENTS **/ - - /** - * Show ConfirmDeletePopup - */ - private void ConfirmDeletePopup_Show() - { - if(CurrentOEGDFile != null) - { - String text = Lang.Get("MSG_SURE_WANT_DELETE").replace("[ITEM]", (CurrentOEGDFile.OEGD.first_name + " " + CurrentOEGDFile.OEGD.last_name)); - PopupConfirmDelete_text.setText(text); - - ConfirmDeletePopup_Overlay.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popup_overlay_in)); - ConfirmDeletePopup_Overlay.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popup_in)); - - if(!ConfirmDeletePopup.isShowing()) - { - ConfirmDeletePopup.showAtLocation(ActivityRootLayout, Gravity.CENTER,0,0); - } - } - } - - /** - * Delete confirmed item - */ - private void ConfirmDeletePopup_BtnYES_Click() - { - try - { - if(CurrentOEGDFile != null) - { - String file = System.GetPathForStorageFile(CurrentOEGDFile.filename, MainContext); - - if(file != null) - { - System.DeleteFile(file); - } - - this.OConfirmDeletePopup_Hide(); - - //this.loadOEGDs(); - - finish(); - overridePendingTransition(0, 0); - startActivity(getIntent()); - overridePendingTransition(0, 0); - } - } - catch (Exception ex) - { - Log.Error(ex.getMessage(), "OEGDActivity", "ConfirmDeletePopup_BtnYES_Click"); - } - } - - /** - * Hide ConfirmDeletePopup - */ - private void OConfirmDeletePopup_Hide() - { - ConfirmDeletePopup_Overlay.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popup_overlay_out)); - ConfirmDeletePopup_Popup.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popup_out)); - - if(ConfirmDeletePopup.isShowing()) - { - Animation anim = AnimationUtils.loadAnimation(this, R.anim.popup_out); - anim.setAnimationListener(new Animation.AnimationListener() - { - @Override - public void onAnimationStart(Animation animation) {} - - @Override - public void onAnimationEnd(Animation animation) - { - ConfirmDeletePopup.dismiss(); - } - - @Override - public void onAnimationRepeat(Animation animation) {} - }); - - anim.setFillAfter(true); - ConfirmDeletePopup_Popup.startAnimation(anim); - } - } - - /** - * Show OEGDOptionsOptions - */ - private void OEGDOptionsOptions_Show() - { - OEGDOptionsOptions_Overlay.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popup_overlay_in)); - OEGDOptionsOptions_Popup.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popup_in)); - - if(!OEGDOptionsOptions.isShowing()) - { - OEGDOptionsOptions.showAtLocation(ActivityRootLayout, Gravity.CENTER,0,0); - } - } - - /** - * Hide OEGDOptionsOptions - */ - private void OEGDOptionsOptions_Hide() - { - OEGDOptionsOptions_Overlay.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popup_overlay_out)); - OEGDOptionsOptions_Popup.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popup_out)); - - if(OEGDOptionsOptions.isShowing()) - { - Animation anim = AnimationUtils.loadAnimation(this, R.anim.popup_out); - anim.setAnimationListener(new Animation.AnimationListener() - { - @Override - public void onAnimationStart(Animation animation) { } - - @Override - public void onAnimationEnd(Animation animation) - { - OEGDOptionsOptions.dismiss(); - } - - @Override - public void onAnimationRepeat(Animation animation) {} - }); - - anim.setFillAfter(true); - OEGDOptionsOptions_Popup.startAnimation(anim); - } - } - - /** - * Go Back to MainActivity - */ - private void OEGDButtonBack_Click() - { - Intent intent = new Intent(this, MainActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - Bundle parameters = new Bundle(); - parameters.putBoolean("SplashScreenLoaded", true); - intent.putExtras(parameters); - startActivity(intent); - overridePendingTransition(R.anim.side_in_left, R.anim.side_out_right); - } - - /** - * On OptionsPopup Add Button clicked - */ - private void OEGDOptionsOptions_BtnAdd_Click() - { - this.OEGDOptionsOptions_Hide(); - this.NewOEGDActivity(); - } - - /** - * Goes to NewOEGDActivity - */ - private void NewOEGDActivity() - { - Intent newOEGDActivity = new Intent(this, NewOEGDActivity.class); - startActivity(newOEGDActivity); - overridePendingTransition(R.anim.side_in_right, R.anim.side_out_left); - } - - /** - * On OptionsPopup Edit Button clicked - */ - private void OEGDOptionsOptions_BtnEdit_Click() - { - this.OEGDOptionsOptions_Hide(); - - if(CurrentOEGDFile != null) - { - this.GoToEditOEGDActivity(CurrentOEGDFile); - } - } - - /** - * GoTo EditOEGDActivity - * - * @param oegdFile - oegd file that should be edited - */ - private void GoToEditOEGDActivity(OEGDFile oegdFile) - { - try - { - Intent editOEGDActivity = new Intent(this, EditOEGDActivity.class); - Bundle parameters = new Bundle(); - parameters.putString("file", oegdFile.filename); - editOEGDActivity.putExtras(parameters); - startActivity(editOEGDActivity); - overridePendingTransition(R.anim.side_in_right, R.anim.side_out_left); - } - catch (Exception ex) - { - Log.Critical(ex.getMessage(), "MainActivity", "GoToEditOEGDActivity"); - } - } - - /** - * On OptionsPopup Delete Button clicked - */ - private void OEGDOptionsOptions_BtnDelete_Click() - { - this.OEGDOptionsOptions_Hide(); - this.ConfirmDeletePopup_Show(); - } - - /** - * On OptionsPopup Cancel Button clicked - */ - private void OEGDOptionsOptions_BtnCancel_Click() - { - this.OEGDOptionsOptions_Hide(); - } - - /** END EVENTS **/ - - /** BEGIN FUNCTIONS **/ - - private void loadOEGDs() - { - this.OEGDFiles = null; - - OEGDMainLoading.setVisibility(View.VISIBLE); - - try - { - /** Run request on sub thread **/ - Thread thread = new Thread(new Runnable() - { - @Override - public void run() - { - List oegdFiles = System.GetOEGDFiles(MainContext); - - if(oegdFiles != null && oegdFiles.size() > 0) - { - OEGDFiles = new ArrayList<>(); - - for(int i = 0; i < oegdFiles.size(); i++) - { - try - { - File f = oegdFiles.get(i); - - byte[] encrypted_content = System.ReadFromStorage(f.getName(), MainContext); - - if(encrypted_content != null) - { - String json = AES.Decrypt(new String(encrypted_content, StandardCharsets.UTF_8), AES.GetKey(Session.DevicePassword)); - - if(json != null) - { - OEGD obj = (OEGD)new Gson().fromJson(json, OEGD.class); - - if(obj != null) - { - OEGDFile oegdFile = new OEGDFile(); - oegdFile.OEGD = obj; - oegdFile.filename = f.getName(); - OEGDFiles.add(oegdFile); - } - } - } - } - catch (Exception ex) - { - Log.Error(ex.getMessage(), "eIDActivity", "loadOEGDs"); - } - } - } - - UpdateOEGDCodes(); - } - }); - - thread.start(); - } - catch (Exception ex) - { - Log.Error(ex.getMessage(), "eIDActivity", "loadOEGDs"); - } - } - - /** - * Updates OEGD QR-Codes on main thread - */ - private void UpdateOEGDCodes() - { - runOnUiThread(new Runnable() - { - @Override - public void run() - { - OEGDMainLoading.setVisibility(View.GONE); - OEGDOptionsEditView.setVisibility(View.GONE); - OEGDOptionsDeleteView.setVisibility(View.GONE); - - if(OEGDFiles != null && OEGDFiles.size() > 0) - { - OEGDOptionsEditView.setVisibility(View.VISIBLE); - OEGDOptionsDeleteView.setVisibility(View.VISIBLE); - Pager.setVisibility(View.VISIBLE); - lblNoOEGD.setVisibility(View.GONE); - - bottomOEGDButtonMenuOpener.clearAnimation(); - } - else - { - Pager.setVisibility(View.GONE); - lblNoOEGD.setVisibility(View.VISIBLE); - - Animation animation = new AlphaAnimation(1, 0); - animation.setDuration(200); - animation.setInterpolator(new LinearInterpolator()); - animation.setRepeatCount(Animation.INFINITE); - animation.setRepeatMode(Animation.REVERSE); - bottomOEGDButtonMenuOpener.startAnimation(animation); - } - - ((OEGDActivity.OEGDPagerAdapter)Adapter).updateDataset(OEGDFiles); - } - }); - } - - /** END FUNCTIONS **/ - - /** OEGDSwitcher Adapter **/ - private class OEGDPagerAdapter extends FragmentStatePagerAdapter - { - /** List of OEGDFiles **/ - private List OEGDFiles = null; - - /** OEGDActivity Context **/ - private OEGDActivity OEGDActivity; - - public OEGDPagerAdapter(FragmentManager fragmentManager, List oegdFiles, OEGDActivity oegdActivity) - { - super(fragmentManager); - this.OEGDFiles = oegdFiles; - this.OEGDActivity = oegdActivity; - - if(this.OEGDFiles == null) - { - this.OEGDFiles = new ArrayList<>(); - } - } - - /** - * Updates dataset - */ - public void updateDataset(List oegdFiles) - { - this.OEGDFiles = oegdFiles; - - if(this.OEGDFiles == null) - { - this.OEGDFiles = new ArrayList<>(); - } - - this.notifyDataSetChanged(); - } - - @Override - public int getCount() - { - return this.OEGDFiles.size(); - } - - @Override - public Fragment getItem(int position) - { - return de.labor_stein.befund.OEGDActivity.OEGDFragment.newInstance(this.OEGDFiles.get(position), this.OEGDActivity); - } - } - - /** OEGDCard Fragment **/ - public static class OEGDFragment extends Fragment - { - /** OEGDActivity Context **/ - private OEGDActivity OEGDActivity; - - /** OEGDFile object **/ - private OEGDFile OEGDFile; - - /** Constructor for OEGDFragment **/ - public OEGDFragment(OEGDFile oegdFile, OEGDActivity oegdActivity) - { - this.OEGDFile = oegdFile; - this.OEGDActivity = oegdActivity; - } - - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) - { - View view = inflater.inflate(R.layout.fragment_oegd_code, container, false); - ImageView qrCode = view.findViewById(R.id.fragment_oegd_qr_code); - - TextView name = view.findViewById(R.id.fragment_oegd_name); - name.setText(this.OEGDFile.OEGD.first_name + " " + this.OEGDFile.OEGD.last_name); - - try - { - String json = new Gson().toJson(this.OEGDFile.OEGD); - - if(json != null && !json.isEmpty()) - { - Bitmap qrCodeImage = ImageHelper.QRCode(json, 350, 350); - - if(qrCodeImage != null) - { - qrCode.setVisibility(View.VISIBLE); - qrCode.setImageBitmap(qrCodeImage); - } - else - { - qrCode.setVisibility(View.INVISIBLE); - } - } - else - { - qrCode.setVisibility(View.INVISIBLE); - } - } - catch (Exception ex) - { - qrCode.setVisibility(View.INVISIBLE); - Log.Error(ex.getMessage(), "OEGDActivity.OEGDFragment", "onCreateView"); - } - - return view; - } - - /** Creates a new instance of fragment **/ - public static de.labor_stein.befund.OEGDActivity.OEGDFragment newInstance(OEGDFile oegdFile, OEGDActivity oegdActivity) - { - return new OEGDActivity.OEGDFragment(oegdFile, oegdActivity); - } - } -} diff --git a/app/src/main/res/layout/activity_edit_oegd.xml b/app/src/main/res/layout/activity_edit_oegd.xml deleted file mode 100644 index a6dbea8..0000000 --- a/app/src/main/res/layout/activity_edit_oegd.xml +++ /dev/null @@ -1,387 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -