Search in sources :

Example 1 with AutofillManager

use of android.view.autofill.AutofillManager in project android_packages_apps_Settings by LineageOS.

the class AutofillPickerTrampolineActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // First check if the current user's service already belongs to the app...
    final Intent intent = getIntent();
    final String packageName = intent.getData().getSchemeSpecificPart();
    final String currentService = DefaultAutofillPicker.getDefaultKey(this);
    if (currentService != null && currentService.startsWith(packageName)) {
        // ...and succeed right away if it does.
        setResult(RESULT_OK);
        finish();
        return;
    }
    // Then check if the Autofill is available for the current user...
    final AutofillManager afm = getSystemService(AutofillManager.class);
    if (afm == null || !afm.hasAutofillFeature() || !afm.isAutofillSupported()) {
        // ... and fail right away if it is not.
        setResult(RESULT_CANCELED);
        finish();
        return;
    }
    // Otherwise, go ahead and show the real UI...
    final Intent newIntent = new Intent(this, AutofillPickerActivity.class).setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT).setData(intent.getData());
    startActivity(newIntent);
    finish();
}
Also used : Intent(android.content.Intent) AutofillManager(android.view.autofill.AutofillManager)

Example 2 with AutofillManager

use of android.view.autofill.AutofillManager in project WordPress-Login-Flow-Android by wordpress-mobile.

the class LoginEmailFragment method showHintPickerDialogIfNeeded.

private void showHintPickerDialogIfNeeded() {
    // If autofill is available and enabled, we favor the active autofill service over the hint picker dialog.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        final AutofillManager autofillManager = requireContext().getSystemService(AutofillManager.class);
        if (autofillManager != null && autofillManager.isEnabled()) {
            AppLog.d(T.NUX, LOG_TAG + ": Autofill framework is enabled. Disabling hint picker dialog.");
            return;
        }
    }
    AppLog.d(T.NUX, LOG_TAG + ": Autofill framework is unavailable or disabled. Showing hint picker dialog.");
    showHintPickerDialog();
}
Also used : AutofillManager(android.view.autofill.AutofillManager)

Example 3 with AutofillManager

use of android.view.autofill.AutofillManager in project platform_packages_apps_Settings by BlissRoms.

the class AutofillPickerTrampolineActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // First check if the current user's service already belongs to the app...
    final Intent intent = getIntent();
    final String packageName = intent.getData().getSchemeSpecificPart();
    final String currentService = DefaultAutofillPicker.getDefaultKey(this);
    if (currentService != null && currentService.startsWith(packageName)) {
        // ...and succeed right away if it does.
        setResult(RESULT_OK);
        finish();
        return;
    }
    // Then check if the Autofill is available for the current user...
    final AutofillManager afm = getSystemService(AutofillManager.class);
    if (afm == null || !afm.hasAutofillFeature() || !afm.isAutofillSupported()) {
        // ... and fail right away if it is not.
        setResult(RESULT_CANCELED);
        finish();
        return;
    }
    // Otherwise, go ahead and show the real UI...
    final Intent newIntent = new Intent(this, AutofillPickerActivity.class).setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT).setData(intent.getData());
    startActivity(newIntent);
    finish();
}
Also used : Intent(android.content.Intent) AutofillManager(android.view.autofill.AutofillManager)

Example 4 with AutofillManager

use of android.view.autofill.AutofillManager in project robolectric by robolectric.

the class ShadowApplicationTest method shouldProvideServicesIntroducedOreo.

@Test
@Config(minSdk = O)
public void shouldProvideServicesIntroducedOreo() throws Exception {
    // Context.AUTOFILL_MANAGER_SERVICE is marked @hide and this is the documented way to obtain
    // this service.
    AutofillManager autofillManager = context.getSystemService(AutofillManager.class);
    assertThat(autofillManager).isNotNull();
    assertThat(context.getSystemService(Context.TEXT_CLASSIFICATION_SERVICE)).isInstanceOf(TextClassificationManager.class);
}
Also used : AutofillManager(android.view.autofill.AutofillManager) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 5 with AutofillManager

use of android.view.autofill.AutofillManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AutofillPreferenceCategory method isAutofillEnabled.

// PreferenceCategory.isEnabled() always return false, so we rather not change that logic
// decide whether the children should be shown using isAutofillEnabled() instead.
private boolean isAutofillEnabled() {
    final AutofillManager afm = getContext().getSystemService(AutofillManager.class);
    final boolean enabled = afm != null && afm.isEnabled();
    Log.v(TAG, "isAutofillEnabled(): " + enabled);
    return enabled;
}
Also used : AutofillManager(android.view.autofill.AutofillManager)

Aggregations

AutofillManager (android.view.autofill.AutofillManager)12 Intent (android.content.Intent)8 ComponentName (android.content.ComponentName)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 DialogInterface (android.content.DialogInterface)1 Resources (android.content.res.Resources)1 Uri (android.net.Uri)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Settings (android.provider.Settings)1 RequiresApi (android.support.annotation.RequiresApi)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1 DialogFragment (android.support.v4.app.DialogFragment)1 FragmentManager (android.support.v4.app.FragmentManager)1 FingerprintManagerCompat (android.support.v4.hardware.fingerprint.FingerprintManagerCompat)1 AlertDialog (android.support.v7.app.AlertDialog)1 Preference (android.support.v7.preference.Preference)1 PreferenceFragmentCompat (android.support.v7.preference.PreferenceFragmentCompat)1 Log (android.util.Log)1 Toast (android.widget.Toast)1