Search in sources :

Example 1 with ServerAuthDialogBinding

use of org.odk.collect.android.databinding.ServerAuthDialogBinding in project collect by opendatakit.

the class ServerAuthDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    ServerAuthDialogBinding binding = ServerAuthDialogBinding.inflate(requireActivity().getLayoutInflater());
    dialogView = binding.getRoot();
    Settings generalSettings = settingsProvider.getUnprotectedSettings();
    binding.usernameEdit.setText(generalSettings.getString(ProjectKeys.KEY_USERNAME));
    binding.passwordEdit.setText(generalSettings.getString(ProjectKeys.KEY_PASSWORD));
    return new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.server_requires_auth).setMessage(requireContext().getString(R.string.server_auth_credentials, generalSettings.getString(ProjectKeys.KEY_SERVER_URL))).setView(dialogView).setPositiveButton(R.string.ok, (dialogInterface, i) -> {
        generalSettings.save(ProjectKeys.KEY_USERNAME, binding.usernameEdit.getText().toString());
        generalSettings.save(ProjectKeys.KEY_PASSWORD, binding.passwordEdit.getText().toString());
    }).create();
}
Also used : Context(android.content.Context) ProjectKeys(org.odk.collect.settings.keys.ProjectKeys) Bundle(android.os.Bundle) SettingsProvider(org.odk.collect.settings.SettingsProvider) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Dialog(android.app.Dialog) Inject(javax.inject.Inject) DaggerUtils(org.odk.collect.android.injection.DaggerUtils) Nullable(androidx.annotation.Nullable) ServerAuthDialogBinding(org.odk.collect.android.databinding.ServerAuthDialogBinding) R(org.odk.collect.android.R) View(android.view.View) Settings(org.odk.collect.shared.settings.Settings) DialogFragment(androidx.fragment.app.DialogFragment) ServerAuthDialogBinding(org.odk.collect.android.databinding.ServerAuthDialogBinding) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Settings(org.odk.collect.shared.settings.Settings) NonNull(androidx.annotation.NonNull)

Aggregations

Dialog (android.app.Dialog)1 Context (android.content.Context)1 Bundle (android.os.Bundle)1 View (android.view.View)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 DialogFragment (androidx.fragment.app.DialogFragment)1 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)1 Inject (javax.inject.Inject)1 R (org.odk.collect.android.R)1 ServerAuthDialogBinding (org.odk.collect.android.databinding.ServerAuthDialogBinding)1 DaggerUtils (org.odk.collect.android.injection.DaggerUtils)1 SettingsProvider (org.odk.collect.settings.SettingsProvider)1 ProjectKeys (org.odk.collect.settings.keys.ProjectKeys)1 Settings (org.odk.collect.shared.settings.Settings)1