Search in sources :

Example 1 with AuthDialogUtility

use of org.odk.collect.android.utilities.AuthDialogUtility in project collect by opendatakit.

the class InstanceUploaderActivity method onCreateDialog.

@Override
protected Dialog onCreateDialog(int id) {
    switch(id) {
        case PROGRESS_DIALOG:
            progressDialog = new DayNightProgressDialog(this);
            DialogInterface.OnClickListener loadingButtonListener = new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    instanceServerUploaderTask.cancel(true);
                    instanceServerUploaderTask.setUploaderListener(null);
                    finish();
                }
            };
            progressDialog.setTitle(getString(R.string.uploading_data));
            progressDialog.setMessage(alertMsg);
            progressDialog.setIndeterminate(true);
            progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            progressDialog.setCancelable(false);
            progressDialog.setButton(getString(R.string.cancel), loadingButtonListener);
            return progressDialog;
        case AUTH_DIALOG:
            Timber.i("onCreateDialog(AUTH_DIALOG): for upload of %d instances!", instancesToSend.length);
            AuthDialogUtility authDialogUtility = new AuthDialogUtility();
            if (username != null && password != null && url != null) {
                authDialogUtility.setCustomUsername(username);
                authDialogUtility.setCustomPassword(password);
            }
            return authDialogUtility.createDialog(this, this, this.url);
    }
    return null;
}
Also used : DialogInterface(android.content.DialogInterface) DayNightProgressDialog(org.odk.collect.android.views.DayNightProgressDialog) AuthDialogUtility(org.odk.collect.android.utilities.AuthDialogUtility)

Example 2 with AuthDialogUtility

use of org.odk.collect.android.utilities.AuthDialogUtility in project collect by opendatakit.

the class FormDownloadListActivity method createAuthDialog.

private void createAuthDialog() {
    viewModel.setAlertShowing(false);
    AuthDialogUtility authDialogUtility = new AuthDialogUtility();
    if (viewModel.getUrl() != null && viewModel.getUsername() != null && viewModel.getPassword() != null) {
        authDialogUtility.setCustomUsername(viewModel.getUsername());
        authDialogUtility.setCustomPassword(viewModel.getPassword());
    }
    DialogUtils.showDialog(authDialogUtility.createDialog(this, this, viewModel.getUrl()), this);
}
Also used : AuthDialogUtility(org.odk.collect.android.utilities.AuthDialogUtility)

Example 3 with AuthDialogUtility

use of org.odk.collect.android.utilities.AuthDialogUtility in project collect by opendatakit.

the class FormDownloadList method onCreateDialog.

@Override
protected Dialog onCreateDialog(int id) {
    switch(id) {
        case PROGRESS_DIALOG:
            Collect.getInstance().getActivityLogger().logAction(this, "onCreateDialog.PROGRESS_DIALOG", "show");
            progressDialog = new ProgressDialog(this);
            DialogInterface.OnClickListener loadingButtonListener = new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Collect.getInstance().getActivityLogger().logAction(this, "onCreateDialog.PROGRESS_DIALOG", "OK");
                    // we use the same progress dialog for both
                    // so whatever isn't null is running
                    dialog.dismiss();
                    if (downloadFormListTask != null) {
                        downloadFormListTask.setDownloaderListener(null);
                        downloadFormListTask.cancel(true);
                        downloadFormListTask = null;
                    }
                    if (downloadFormsTask != null) {
                        showDialog(CANCELLATION_DIALOG);
                        downloadFormsTask.cancel(true);
                    }
                }
            };
            progressDialog.setTitle(getString(R.string.downloading_data));
            progressDialog.setMessage(alertMsg);
            progressDialog.setIcon(android.R.drawable.ic_dialog_info);
            progressDialog.setIndeterminate(true);
            progressDialog.setCancelable(false);
            progressDialog.setButton(getString(R.string.cancel), loadingButtonListener);
            return progressDialog;
        case AUTH_DIALOG:
            Collect.getInstance().getActivityLogger().logAction(this, "onCreateDialog.AUTH_DIALOG", "show");
            alertShowing = false;
            return new AuthDialogUtility().createDialog(this, this, null);
        case CANCELLATION_DIALOG:
            cancelDialog = new ProgressDialog(this);
            cancelDialog.setTitle(getString(R.string.canceling));
            cancelDialog.setMessage(getString(R.string.please_wait));
            cancelDialog.setIcon(android.R.drawable.ic_dialog_info);
            cancelDialog.setIndeterminate(true);
            cancelDialog.setCancelable(false);
            return cancelDialog;
    }
    return null;
}
Also used : DialogInterface(android.content.DialogInterface) OnClickListener(android.view.View.OnClickListener) ProgressDialog(android.app.ProgressDialog) AuthDialogUtility(org.odk.collect.android.utilities.AuthDialogUtility)

Aggregations

AuthDialogUtility (org.odk.collect.android.utilities.AuthDialogUtility)3 DialogInterface (android.content.DialogInterface)2 ProgressDialog (android.app.ProgressDialog)1 OnClickListener (android.view.View.OnClickListener)1 DayNightProgressDialog (org.odk.collect.android.views.DayNightProgressDialog)1