use of android.view.autofill.AutofillManager in project android_packages_apps_Settings by omnirom.
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;
}
use of android.view.autofill.AutofillManager in project android_packages_apps_Settings by DirtyUnicorns.
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();
}
use of android.view.autofill.AutofillManager in project android_packages_apps_Settings by crdroidandroid.
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();
}
use of android.view.autofill.AutofillManager in project KeePassDX by Kunzisoft.
the class NestedSettingsFragment method onCreatePreferences.
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
int key = getArguments().getInt(TAG_KEY);
// Load the preferences from an XML resource
switch(key) {
case NESTED_SCREEN_APP_KEY:
setPreferencesFromResource(R.xml.app_preferences, rootKey);
Preference keyFile = findPreference(getString(R.string.keyfile_key));
keyFile.setOnPreferenceChangeListener((preference, newValue) -> {
Boolean value = (Boolean) newValue;
if (!value) {
App.getFileHistory().deleteAllKeys();
}
return true;
});
Preference recentHistory = findPreference(getString(R.string.recentfile_key));
recentHistory.setOnPreferenceChangeListener((preference, newValue) -> {
Boolean value = (Boolean) newValue;
if (value == null) {
value = true;
}
if (!value) {
App.getFileHistory().deleteAll();
}
return true;
});
Preference stylePreference = findPreference(getString(R.string.setting_style_key));
stylePreference.setOnPreferenceChangeListener((preference, newValue) -> {
String styleString = (String) newValue;
Stylish.assignStyle(getActivity(), styleString);
getActivity().recreate();
return true;
});
SwitchPreference fingerprintEnablePreference = (SwitchPreference) findPreference(getString(R.string.fingerprint_enable_key));
// < M solve verifyError exception
boolean fingerprintSupported = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
fingerprintSupported = FingerPrintHelper.isFingerprintSupported(FingerprintManagerCompat.from(getContext()));
if (!fingerprintSupported) {
// False if under Marshmallow
fingerprintEnablePreference.setChecked(false);
fingerprintEnablePreference.setOnPreferenceClickListener(preference -> {
FragmentManager fragmentManager = getFragmentManager();
assert fragmentManager != null;
((SwitchPreference) preference).setChecked(false);
UnavailableFeatureDialogFragment.getInstance(Build.VERSION_CODES.M).show(getFragmentManager(), "unavailableFeatureDialog");
return false;
});
}
Preference deleteKeysFingerprints = findPreference(getString(R.string.fingerprint_delete_all_key));
if (!fingerprintSupported) {
deleteKeysFingerprints.setEnabled(false);
} else {
deleteKeysFingerprints.setOnPreferenceClickListener(preference -> {
new AlertDialog.Builder(getContext()).setMessage(getResources().getString(R.string.fingerprint_delete_all_warning)).setIcon(getResources().getDrawable(android.R.drawable.ic_dialog_alert)).setPositiveButton(getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onClick(DialogInterface dialog, int which) {
FingerPrintHelper.deleteEntryKeyInKeystoreForFingerprints(getContext(), new FingerPrintHelper.FingerPrintErrorCallback() {
@Override
public void onInvalidKeyException(Exception e) {
}
@Override
public void onFingerPrintException(Exception e) {
Toast.makeText(getContext(), getString(R.string.fingerprint_error, e.getLocalizedMessage()), Toast.LENGTH_SHORT).show();
}
});
PreferencesUtil.deleteAllValuesFromNoBackupPreferences(getContext());
}
}).setNegativeButton(getResources().getString(android.R.string.no), (dialog, which) -> {
}).show();
return false;
});
}
break;
case NESTED_SCREEN_FORM_FILLING_KEY:
setPreferencesFromResource(R.xml.form_filling_preferences, rootKey);
SwitchPreference autoFillEnablePreference = (SwitchPreference) findPreference(getString(R.string.settings_autofill_enable_key));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
AutofillManager autofillManager = getActivity().getSystemService(AutofillManager.class);
if (autofillManager != null && autofillManager.hasEnabledAutofillServices())
autoFillEnablePreference.setChecked(autofillManager.hasEnabledAutofillServices());
autoFillEnablePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public boolean onPreferenceClick(Preference preference) {
if (((SwitchPreference) preference).isChecked()) {
try {
startEnableService();
} catch (ActivityNotFoundException e) {
String error = getString(R.string.error_autofill_enable_service);
((SwitchPreference) preference).setChecked(false);
Log.d(getClass().getName(), error, e);
Toast.makeText(getContext(), error, Toast.LENGTH_SHORT).show();
}
} else {
disableService();
}
return false;
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void disableService() {
if (autofillManager != null && autofillManager.hasEnabledAutofillServices()) {
autofillManager.disableAutofillServices();
} else {
Log.d(getClass().getName(), "Sample service already disabled.");
}
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void startEnableService() throws ActivityNotFoundException {
if (autofillManager != null && !autofillManager.hasEnabledAutofillServices()) {
Intent intent = new Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE);
intent.setData(Uri.parse("package:com.example.android.autofill.service"));
Log.d(getClass().getName(), "enableService(): intent=" + intent);
startActivityForResult(intent, REQUEST_CODE_AUTOFILL);
} else {
Log.d(getClass().getName(), "Sample service already enabled.");
}
}
});
} else {
autoFillEnablePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
((SwitchPreference) preference).setChecked(false);
FragmentManager fragmentManager = getFragmentManager();
assert fragmentManager != null;
UnavailableFeatureDialogFragment.getInstance(Build.VERSION_CODES.O).show(fragmentManager, "unavailableFeatureDialog");
}
return false;
}
});
}
break;
case NESTED_SCREEN_DB_KEY:
setPreferencesFromResource(R.xml.db_preferences, rootKey);
Database db = App.getDB();
if (db.Loaded()) {
if (db.pm.algorithmSettingsEnabled()) {
Preference roundPref = findPreference(getString(R.string.rounds_key));
roundPref.setEnabled(true);
roundPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
setRounds(App.getDB(), preference);
return true;
}
});
setRounds(db, roundPref);
// TODO Algo
Preference algorithmPref = findPreference(getString(R.string.algorithm_key));
// algorithmPref.setEnabled(true);
setAlgorithm(db, algorithmPref);
}
if (db.pm.isRecycleBinAvailable()) {
SwitchPreference recycleBinPref = (SwitchPreference) findPreference(getString(R.string.recycle_bin_key));
// TODO Recycle
// recycleBinPref.setEnabled(true);
recycleBinPref.setChecked(db.pm.isRecycleBinEnable());
}
} else {
Log.e(getClass().getName(), "Database isn't ready");
}
break;
default:
break;
}
}
use of android.view.autofill.AutofillManager in project android_packages_apps_Settings by SudaMod.
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();
}
Aggregations