Search in sources :

Example 1 with AutofillHelper

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());
    }
}
Also used : KeyFileHelper(com.keepassdroid.fileselect.KeyFileHelper) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) FingerPrintAnimatedVector(com.keepassdroid.fingerprint.FingerPrintAnimatedVector) View(android.view.View) TextView(android.widget.TextView) AutofillHelper(com.keepassdroid.autofill.AutofillHelper) Toolbar(android.support.v7.widget.Toolbar)

Example 2 with AutofillHelper

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());
            }
        }
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) FileNameView(com.keepassdroid.view.FileNameView) RecyclerView(android.support.v7.widget.RecyclerView) Uri(android.net.Uri) File(java.io.File) AutofillHelper(com.keepassdroid.autofill.AutofillHelper) Toolbar(android.support.v7.widget.Toolbar)

Example 3 with AutofillHelper

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();
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) GroupEditDialogFragment(com.keepassdroid.dialogs.GroupEditDialogFragment) AutofillHelper(com.keepassdroid.autofill.AutofillHelper) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Toolbar (android.support.v7.widget.Toolbar)3 AutofillHelper (com.keepassdroid.autofill.AutofillHelper)3 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 SharedPreferences (android.content.SharedPreferences)1 Uri (android.net.Uri)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 TextView (android.widget.TextView)1 GroupEditDialogFragment (com.keepassdroid.dialogs.GroupEditDialogFragment)1 KeyFileHelper (com.keepassdroid.fileselect.KeyFileHelper)1 FingerPrintAnimatedVector (com.keepassdroid.fingerprint.FingerPrintAnimatedVector)1 FileNameView (com.keepassdroid.view.FileNameView)1 File (java.io.File)1