Search in sources :

Example 1 with ConfirmationDialog

use of de.symeda.sormas.app.component.dialog.ConfirmationDialog in project SORMAS-Project by hzi-braunschweig.

the class AppUpdateController method buildInstallFailedDialog.

private ConfirmationDialog buildInstallFailedDialog() {
    dismissExistingDialog();
    int headingResId = R.string.heading_install_app_failed;
    int subHeadingResId = R.string.message_install_app_failed;
    int positiveButtonTextResId = R.string.action_redownload_app;
    int negativeButtonTextResId = allowDismiss ? R.string.action_redownload_app_later : R.string.action_close_app;
    final ConfirmationDialog installFailedDialog = new ConfirmationDialog(activity, headingResId, subHeadingResId, positiveButtonTextResId, negativeButtonTextResId);
    installFailedDialog.setCancelable(false);
    installFailedDialog.setPositiveCallback(() -> downloadNewAppVersion());
    if (allowDismiss) {
        installFailedDialog.setNegativeCallback(dismissCallback);
    } else {
        installFailedDialog.setNegativeCallback(() -> ((SormasApplication) activity.getApplication()).closeApp(activity));
    }
    return installFailedDialog;
}
Also used : ConfirmationDialog(de.symeda.sormas.app.component.dialog.ConfirmationDialog)

Example 2 with ConfirmationDialog

use of de.symeda.sormas.app.component.dialog.ConfirmationDialog in project SORMAS-Project by hzi-braunschweig.

the class AppUpdateController method buildInstallNotPossibleDialog.

private ConfirmationDialog buildInstallNotPossibleDialog() {
    dismissExistingDialog();
    int headingResId = R.string.heading_install_app_failed;
    int subHeadingResId = R.string.message_install_app_not_possible;
    int positiveButtonTextResId = allowDismiss ? R.string.action_ok : R.string.action_close_app;
    ConfirmationDialog installNotPossibleDialog = new ConfirmationDialog(activity, headingResId, subHeadingResId, positiveButtonTextResId, -1);
    installNotPossibleDialog.setCancelable(false);
    installNotPossibleDialog.getNegativeButton().setVisibility(GONE);
    if (allowDismiss) {
        installNotPossibleDialog.setPositiveCallback(dismissCallback);
    } else {
        installNotPossibleDialog.setPositiveCallback(() -> ((SormasApplication) activity.getApplication()).closeApp(activity));
    }
    return installNotPossibleDialog;
}
Also used : ConfirmationDialog(de.symeda.sormas.app.component.dialog.ConfirmationDialog)

Example 3 with ConfirmationDialog

use of de.symeda.sormas.app.component.dialog.ConfirmationDialog in project SORMAS-Project by hzi-braunschweig.

the class SettingsFragment method showRepullDataConfirmationDialog.

private void showRepullDataConfirmationDialog() {
    final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.info_resync_duration);
    confirmationDialog.setPositiveCallback(() -> {
        // Collect unsynchronized changes
        final List<Case> modifiedCases = DatabaseHelper.getCaseDao().getModifiedEntities();
        final List<Contact> modifiedContacts = DatabaseHelper.getContactDao().getModifiedEntities();
        final List<Person> modifiedPersons = DatabaseHelper.getPersonDao().getModifiedEntities();
        final List<Event> modifiedEvents = DatabaseHelper.getEventDao().getModifiedEntities();
        final List<EventParticipant> modifiedEventParticipants = DatabaseHelper.getEventParticipantDao().getModifiedEntities();
        final List<Sample> modifiedSamples = DatabaseHelper.getSampleDao().getModifiedEntities();
        final List<Visit> modifiedVisits = DatabaseHelper.getVisitDao().getModifiedEntities();
        getBaseActivity().synchronizeData(SynchronizeDataAsync.SyncMode.CompleteAndRepull, true, true, null, new Callback() {

            @Override
            public void call() {
                // Add deleted entities that had unsynchronized changes to sync log
                for (Case caze : modifiedCases) {
                    if (DatabaseHelper.getCaseDao().queryUuidReference(caze.getUuid()) == null) {
                        DatabaseHelper.getSyncLogDao().createWithParentStack(caze.toString(), getResources().getString(R.string.caption_changed_data_lost));
                    }
                }
                for (Contact contact : modifiedContacts) {
                    if (DatabaseHelper.getContactDao().queryUuidReference(contact.getUuid()) == null) {
                        DatabaseHelper.getSyncLogDao().createWithParentStack(contact.toString(), getResources().getString(R.string.caption_changed_data_lost));
                    }
                }
                for (Person person : modifiedPersons) {
                    if (DatabaseHelper.getPersonDao().queryUuidReference(person.getUuid()) == null) {
                        DatabaseHelper.getSyncLogDao().createWithParentStack(person.toString(), getResources().getString(R.string.caption_changed_data_lost));
                    }
                }
                for (Event event : modifiedEvents) {
                    if (DatabaseHelper.getEventDao().queryUuidReference(event.getUuid()) == null) {
                        DatabaseHelper.getSyncLogDao().createWithParentStack(event.toString(), getResources().getString(R.string.caption_changed_data_lost));
                    }
                }
                for (EventParticipant eventParticipant : modifiedEventParticipants) {
                    if (DatabaseHelper.getEventParticipantDao().queryUuidReference(eventParticipant.getUuid()) == null) {
                        DatabaseHelper.getSyncLogDao().createWithParentStack(eventParticipant.toString(), getResources().getString(R.string.caption_changed_data_lost));
                    }
                }
                for (Sample sample : modifiedSamples) {
                    if (DatabaseHelper.getSampleDao().queryUuidReference(sample.getUuid()) == null) {
                        DatabaseHelper.getSyncLogDao().createWithParentStack(sample.toString(), getResources().getString(R.string.caption_changed_data_lost));
                    }
                }
                for (Visit visit : modifiedVisits) {
                    if (DatabaseHelper.getVisitDao().queryUuidReference(visit.getUuid()) == null) {
                        DatabaseHelper.getSyncLogDao().createWithParentStack(visit.toString(), getResources().getString(R.string.caption_changed_data_lost));
                    }
                }
            }
        }, new Callback() {

            @Override
            public void call() {
                DatabaseHelper.clearTables(false);
            }
        });
    });
    confirmationDialog.show();
}
Also used : Sample(de.symeda.sormas.app.backend.sample.Sample) Visit(de.symeda.sormas.app.backend.visit.Visit) ConfirmationDialog(de.symeda.sormas.app.component.dialog.ConfirmationDialog) Case(de.symeda.sormas.app.backend.caze.Case) Contact(de.symeda.sormas.app.backend.contact.Contact) Callback(de.symeda.sormas.app.util.Callback) Event(de.symeda.sormas.app.backend.event.Event) Person(de.symeda.sormas.app.backend.person.Person) EventParticipant(de.symeda.sormas.app.backend.event.EventParticipant)

Example 4 with ConfirmationDialog

use of de.symeda.sormas.app.component.dialog.ConfirmationDialog in project SORMAS-Project by hzi-braunschweig.

the class ReportFragment method showSubmitReportConfirmationDialog.

private void showSubmitReportConfirmationDialog() {
    final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.info_add_cases_before_report_submit, R.string.action_submit_report, R.string.action_cancel);
    confirmationDialog.setPositiveCallback(() -> {
        confirmReportTask = new DefaultAsyncTask(getContext()) {

            @Override
            public void onPreExecute() {
                getBaseActivity().showPreloader();
            }

            @Override
            public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
                WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().build(getEpiWeek());
                DatabaseHelper.getWeeklyReportDao().saveAndSnapshot(weeklyReport);
            }

            @Override
            protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
                super.onPostExecute(taskResult);
                getBaseActivity().hidePreloader();
                Intent intent = new Intent(getContext(), ReportActivity.class);
                getContext().startActivity(intent);
                if (!taskResult.getResultStatus().isSuccess()) {
                    NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.ERROR, taskResult.getResultStatus().getMessage());
                    return;
                }
                NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.SUCCESS, R.string.message_weekly_report_submitted);
            }
        }.executeOnThreadPool();
    });
    confirmationDialog.show();
}
Also used : DefaultAsyncTask(de.symeda.sormas.app.core.async.DefaultAsyncTask) TaskResultHolder(de.symeda.sormas.app.core.async.TaskResultHolder) AsyncTaskResult(de.symeda.sormas.app.core.async.AsyncTaskResult) WeeklyReport(de.symeda.sormas.app.backend.report.WeeklyReport) Intent(android.content.Intent) ConfirmationDialog(de.symeda.sormas.app.component.dialog.ConfirmationDialog)

Example 5 with ConfirmationDialog

use of de.symeda.sormas.app.component.dialog.ConfirmationDialog in project SORMAS-Project by hzi-braunschweig.

the class AggregateReportsFragment method showSubmitCaseNumbersConfirmationDialog.

private void showSubmitCaseNumbersConfirmationDialog() {
    final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.info_add_cases_before_report_submit, R.string.action_submit_case_numbers, R.string.action_cancel);
    confirmationDialog.setPositiveCallback(() -> {
        confirmCaseNumbersTask = new DefaultAsyncTask(getContext()) {

            @Override
            public void onPreExecute() {
                getBaseActivity().showPreloader();
            }

            @Override
            public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
                for (AggregateReport report : reports) {
                    // Don't save if a generated report has no case numbers
                    if (report.getLocalChangeDate() == null && (report.getNewCases() == null || report.getNewCases() == 0) && (report.getLabConfirmations() == null || report.getLabConfirmations() == 0) && (report.getDeaths() == null || report.getDeaths() == 0)) {
                        continue;
                    }
                    if (report.getNewCases() == null) {
                        report.setNewCases(0);
                    }
                    if (report.getLabConfirmations() == null) {
                        report.setLabConfirmations(0);
                    }
                    if (report.getDeaths() == null) {
                        report.setDeaths(0);
                    }
                    DatabaseHelper.getAggregateReportDao().saveAndSnapshot(report);
                }
            }

            @Override
            protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
                super.onPostExecute(taskResult);
                getBaseActivity().hidePreloader();
                Intent intent = new Intent(getContext(), AggregateReportsActivity.class);
                getContext().startActivity(intent);
                if (!taskResult.getResultStatus().isSuccess()) {
                    NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.ERROR, taskResult.getResultStatus().getMessage());
                    return;
                }
                NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.SUCCESS, R.string.message_case_numbers_submitted);
            }
        }.executeOnThreadPool();
    });
    confirmationDialog.show();
}
Also used : DefaultAsyncTask(de.symeda.sormas.app.core.async.DefaultAsyncTask) TaskResultHolder(de.symeda.sormas.app.core.async.TaskResultHolder) AsyncTaskResult(de.symeda.sormas.app.core.async.AsyncTaskResult) AggregateReport(de.symeda.sormas.app.backend.report.AggregateReport) Intent(android.content.Intent) ConfirmationDialog(de.symeda.sormas.app.component.dialog.ConfirmationDialog)

Aggregations

ConfirmationDialog (de.symeda.sormas.app.component.dialog.ConfirmationDialog)16 Case (de.symeda.sormas.app.backend.caze.Case)4 AsyncTaskResult (de.symeda.sormas.app.core.async.AsyncTaskResult)3 TaskResultHolder (de.symeda.sormas.app.core.async.TaskResultHolder)3 Intent (android.content.Intent)2 SQLException (android.database.SQLException)2 Disease (de.symeda.sormas.api.Disease)2 DiseaseVariant (de.symeda.sormas.api.disease.DiseaseVariant)2 PathogenTest (de.symeda.sormas.app.backend.sample.PathogenTest)2 ControlPropertyField (de.symeda.sormas.app.component.controls.ControlPropertyField)2 ValueChangeListener (de.symeda.sormas.app.component.controls.ValueChangeListener)2 DefaultAsyncTask (de.symeda.sormas.app.core.async.DefaultAsyncTask)2 Date (java.util.Date)2 FragmentActivity (androidx.fragment.app.FragmentActivity)1 CaseClassification (de.symeda.sormas.api.caze.CaseClassification)1 CaseConfirmationBasis (de.symeda.sormas.api.caze.CaseConfirmationBasis)1 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 ContactProximity (de.symeda.sormas.api.contact.ContactProximity)1 ValidationException (de.symeda.sormas.api.utils.ValidationException)1 DaoException (de.symeda.sormas.app.backend.common.DaoException)1