Search in sources :

Example 1 with KEY_SELECTED_GOOGLE_ACCOUNT

use of org.odk.collect.settings.keys.ProjectKeys.KEY_SELECTED_GOOGLE_ACCOUNT in project collect by opendatakit.

the class ServerPreferencesFragment method runGoogleAccountValidation.

private void runGoogleAccountValidation() {
    String account = settingsProvider.getUnprotectedSettings().getString(KEY_SELECTED_GOOGLE_ACCOUNT);
    String protocol = settingsProvider.getUnprotectedSettings().getString(KEY_PROTOCOL);
    if (TextUtils.isEmpty(account) && protocol.equals(ProjectKeys.PROTOCOL_GOOGLE_SHEETS)) {
        AlertDialog alertDialog = new MaterialAlertDialogBuilder(getActivity()).setTitle(R.string.missing_google_account_dialog_title).setMessage(R.string.missing_google_account_dialog_desc).setPositiveButton(getString(R.string.ok), (dialog, which) -> dialog.dismiss()).create();
        showDialog(alertDialog, getActivity());
    } else {
        continueOnBackPressed();
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Context(android.content.Context) Analytics(org.odk.collect.analytics.Analytics) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) RESULT_OK(android.app.Activity.RESULT_OK) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Intent(android.content.Intent) PermissionListener(org.odk.collect.permissions.PermissionListener) Inject(javax.inject.Inject) DaggerUtils(org.odk.collect.android.injection.DaggerUtils) ByteArrayInputStream(java.io.ByteArrayInputStream) GoogleAccountsManager(org.odk.collect.android.gdrive.GoogleAccountsManager) ToastUtils(org.odk.collect.androidshared.ui.ToastUtils) R(org.odk.collect.android.R) EditTextPreference(androidx.preference.EditTextPreference) ControlCharacterFilter(org.odk.collect.android.preferences.filters.ControlCharacterFilter) PermissionsProvider(org.odk.collect.permissions.PermissionsProvider) AccountManager(android.accounts.AccountManager) KEY_PROTOCOL(org.odk.collect.settings.keys.ProjectKeys.KEY_PROTOCOL) ProjectKeys(org.odk.collect.settings.keys.ProjectKeys) Validator(org.odk.collect.shared.strings.Validator) SET_FALLBACK_SHEETS_URL(org.odk.collect.android.analytics.AnalyticsEvents.SET_FALLBACK_SHEETS_URL) TextUtils(android.text.TextUtils) Preference(androidx.preference.Preference) FormUpdateScheduler(org.odk.collect.android.backgroundwork.FormUpdateScheduler) OnBackPressedListener(org.odk.collect.android.listeners.OnBackPressedListener) PlayServicesChecker(org.odk.collect.android.utilities.PlayServicesChecker) DialogUtils.showDialog(org.odk.collect.android.utilities.DialogUtils.showDialog) ListPreference(androidx.preference.ListPreference) Md5(org.odk.collect.shared.strings.Md5) KEY_SELECTED_GOOGLE_ACCOUNT(org.odk.collect.settings.keys.ProjectKeys.KEY_SELECTED_GOOGLE_ACCOUNT) InputFilter(android.text.InputFilter) NotNull(org.jetbrains.annotations.NotNull) ServerPreferencesAdder(org.odk.collect.android.preferences.ServerPreferencesAdder) WhitespaceFilter(org.odk.collect.android.preferences.filters.WhitespaceFilter) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Aggregations

AccountManager (android.accounts.AccountManager)1 RESULT_OK (android.app.Activity.RESULT_OK)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 InputFilter (android.text.InputFilter)1 TextUtils (android.text.TextUtils)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 EditTextPreference (androidx.preference.EditTextPreference)1 ListPreference (androidx.preference.ListPreference)1 Preference (androidx.preference.Preference)1 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Inject (javax.inject.Inject)1 NotNull (org.jetbrains.annotations.NotNull)1 Analytics (org.odk.collect.analytics.Analytics)1 R (org.odk.collect.android.R)1 SET_FALLBACK_SHEETS_URL (org.odk.collect.android.analytics.AnalyticsEvents.SET_FALLBACK_SHEETS_URL)1 FormUpdateScheduler (org.odk.collect.android.backgroundwork.FormUpdateScheduler)1 GoogleAccountsManager (org.odk.collect.android.gdrive.GoogleAccountsManager)1