Search in sources :

Example 11 with AutofillManager

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

the class AutofillPickerTrampolineActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final AutofillManager afm = getSystemService(AutofillManager.class);
    // First check if the Autofill is available for the current user...
    if (afm == null || !afm.hasAutofillFeature() || !afm.isAutofillSupported()) {
        // ... and fail right away if it is not.
        setResult(RESULT_CANCELED);
        finish();
        return;
    }
    // Then check if the current user's service already belongs to the app...
    final Intent intent = getIntent();
    final String packageName = intent.getData().getSchemeSpecificPart();
    final ComponentName currentService = afm.getAutofillServiceComponentName();
    if (currentService != null && currentService.getPackageName().equals(packageName)) {
        // ...and succeed right away if it does.
        setResult(RESULT_OK);
        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) ComponentName(android.content.ComponentName) AutofillManager(android.view.autofill.AutofillManager)

Example 12 with AutofillManager

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

the class AutofillPickerTrampolineActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final AutofillManager afm = getSystemService(AutofillManager.class);
    // First check if the Autofill is available for the current user...
    if (afm == null || !afm.hasAutofillFeature() || !afm.isAutofillSupported()) {
        // ... and fail right away if it is not.
        setResult(RESULT_CANCELED);
        finish();
        return;
    }
    // Then check if the current user's service already belongs to the app...
    final Intent intent = getIntent();
    final String packageName = intent.getData().getSchemeSpecificPart();
    final ComponentName currentService = afm.getAutofillServiceComponentName();
    if (currentService != null && currentService.getPackageName().equals(packageName)) {
        // ...and succeed right away if it does.
        setResult(RESULT_OK);
        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) ComponentName(android.content.ComponentName) 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