use of com.keepassdroid.autofill.AutofillHelper in project KeePassDX by Kunzisoft.
the class PasswordActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefsNoBackup = PreferencesUtil.getNoBackupSharedPreferences(getApplicationContext());
mRememberKeyfile = prefs.getBoolean(getString(R.string.keyfile_key), getResources().getBoolean(R.bool.keyfile_default));
setContentView(R.layout.password);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(getString(R.string.app_name));
setSupportActionBar(toolbar);
assert getSupportActionBar() != null;
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
confirmButtonView = findViewById(R.id.pass_ok);
filenameView = findViewById(R.id.filename);
passwordView = findViewById(R.id.password);
keyFileView = findViewById(R.id.pass_keyfile);
checkboxPasswordView = findViewById(R.id.password_checkbox);
checkboxKeyfileView = findViewById(R.id.keyfile_checkox);
checkboxDefaultDatabaseView = findViewById(R.id.default_database);
View browseView = findViewById(R.id.browse_button);
keyFileHelper = new KeyFileHelper(PasswordActivity.this);
browseView.setOnClickListener(keyFileHelper.getOpenFileOnClickViewListener());
passwordView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (!editable.toString().isEmpty() && !checkboxPasswordView.isChecked())
checkboxPasswordView.setChecked(true);
}
});
keyFileView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (!editable.toString().isEmpty() && !checkboxKeyfileView.isChecked())
checkboxKeyfileView.setChecked(true);
}
});
defaultCheckChange = new DefaultCheckChange();
validateButtonViewClickListener = new ValidateButtonViewClickListener();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
fingerprintContainerView = findViewById(R.id.fingerprint_container);
fingerprintTextView = findViewById(R.id.fingerprint_label);
initForFingerprint();
fingerPrintAnimatedVector = new FingerPrintAnimatedVector(this, findViewById(R.id.fingerprint_image));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
autofillHelper = new AutofillHelper();
autofillHelper.retrieveAssistStructure(getIntent());
}
}
use of com.keepassdroid.autofill.AutofillHelper in project KeePassDX by Kunzisoft.
the class FileSelectActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (AutofillHelper.isIntentContainsExtraAssistStructureKey(getIntent()))
consultationMode = true;
}
fileHistory = App.getFileHistory();
setContentView(R.layout.file_selection);
fileListTitle = findViewById(R.id.file_list_title);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(getString(R.string.app_name));
setSupportActionBar(toolbar);
openFileNameView = (EditText) findViewById(R.id.file_filename);
fileNameView = (FileNameView) findViewById(R.id.file_select);
// Set the initial value of the filename
defaultPath = Environment.getExternalStorageDirectory().getAbsolutePath() + getString(R.string.database_file_path_default) + getString(R.string.database_file_name_default) + getString(R.string.database_file_extension_default);
openFileNameView.setHint(defaultPath);
RecyclerView mListFiles = (RecyclerView) findViewById(R.id.file_list);
mListFiles.setLayoutManager(new LinearLayoutManager(this));
// To retrieve info for AutoFill
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
autofillHelper = new AutofillHelper();
autofillHelper.retrieveAssistStructure(getIntent());
}
// Open button
View openButton = findViewById(R.id.open_database);
openButton.setOnClickListener(v -> {
String fileName = openFileNameView.getText().toString();
if (fileName.isEmpty())
fileName = defaultPath;
launchPasswordActivityWithPath(fileName);
});
// Create button
View createButton = findViewById(R.id.create_database);
createButton.setOnClickListener(v -> FileSelectActivityPermissionsDispatcher.openCreateFileDialogFragmentWithPermissionCheck(FileSelectActivity.this));
keyFileHelper = new KeyFileHelper(this);
View browseButton = findViewById(R.id.browse_button);
browseButton.setOnClickListener(keyFileHelper.getOpenFileOnClickViewListener(() -> Uri.parse("file://" + openFileNameView.getText().toString())));
// Construct adapter with listeners
mAdapter = new FileSelectAdapter(FileSelectActivity.this, fileHistory.getDbList());
mAdapter.setOnItemClickListener(this);
mAdapter.setFileSelectClearListener(this);
mAdapter.setFileInformationShowListener(this);
mListFiles.setAdapter(mAdapter);
// Load default database if not an orientation change
if (!(savedInstanceState != null && savedInstanceState.containsKey(EXTRA_STAY) && savedInstanceState.getBoolean(EXTRA_STAY, false))) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String fileName = prefs.getString(PasswordActivity.KEY_DEFAULT_FILENAME, "");
if (fileName.length() > 0) {
Uri dbUri = UriUtil.parseDefaultFile(fileName);
String scheme = null;
if (dbUri != null)
scheme = dbUri.getScheme();
if (!EmptyUtils.isNullOrEmpty(scheme) && scheme.equalsIgnoreCase("file")) {
String path = dbUri.getPath();
File db = new File(path);
if (db.exists()) {
launchPasswordActivityWithPath(path);
}
} else {
if (dbUri != null)
launchPasswordActivityWithPath(dbUri.toString());
}
}
}
}
use of com.keepassdroid.autofill.AutofillHelper in project KeePassDX by Kunzisoft.
the class GroupActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.w(TAG, "Retrieved tree");
if (mCurrentGroup == null) {
Log.w(TAG, "Group was null");
return;
}
// Construct main view
setContentView(getLayoutInflater().inflate(R.layout.list_nodes_with_add_button, null));
addNodeButtonView = findViewById(R.id.add_node_button);
addNodeButtonView.enableAddGroup(addGroupEnabled);
addNodeButtonView.enableAddEntry(addEntryEnabled);
// Hide when scroll
RecyclerView recyclerView = findViewById(R.id.nodes_list);
recyclerView.addOnScrollListener(addNodeButtonView.hideButtonOnScrollListener());
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("");
setSupportActionBar(toolbar);
if (mCurrentGroup.getParent() != null)
toolbar.setNavigationIcon(R.drawable.ic_arrow_up_white_24dp);
addNodeButtonView.setAddGroupClickListener(v -> {
editGroupDialogAction = EditGroupDialogAction.CREATION;
GroupEditDialogFragment groupEditDialogFragment = new GroupEditDialogFragment();
groupEditDialogFragment.show(getSupportFragmentManager(), GroupEditDialogFragment.TAG_CREATE_GROUP);
});
addNodeButtonView.setAddEntryClickListener(v -> EntryEditActivity.Launch(GroupActivity.this, mCurrentGroup));
setGroupTitle();
setGroupIcon();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
autofillHelper = new AutofillHelper();
autofillHelper.retrieveAssistStructure(getIntent());
}
Log.w(TAG, "Finished creating tree");
if (isRoot) {
showWarnings();
}
}
Aggregations