mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-03 23:32:28 -08:00
Add dialog to create database file
This commit is contained in:
1 parent
e6cc9b628e
commit
ec2dd3db64
9 files changed
+230
-8
No files matched your search
@@ -78,6 +78,7 @@ public class AssignPasswordDialog extends DialogFragment {
|
||||
|
||||
rootView = inflater.inflate(R.layout.set_password, null);
|
||||
builder.setView(rootView)
|
||||
.setTitle(R.string.assign_master_key)
|
||||
// Add action buttons
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.keepassdroid;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
|
||||
public class CreateFileDialog extends DialogFragment implements AdapterView.OnItemSelectedListener{
|
||||
|
||||
private View rootView;
|
||||
private DefinePathDialogListener mListener;
|
||||
|
||||
public interface DefinePathDialogListener {
|
||||
void onDefinePathDialogPositiveClick(Uri pathFile);
|
||||
void onDefinePathDialogNegativeClick(Uri pathFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context activity) {
|
||||
super.onAttach(activity);
|
||||
try {
|
||||
mListener = (DefinePathDialogListener) activity;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(activity.toString()
|
||||
+ " must implement " + DefinePathDialogListener.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
|
||||
rootView = inflater.inflate(R.layout.file_creation, null);
|
||||
builder.setView(rootView)
|
||||
.setTitle(R.string.create_keepass_file)
|
||||
// Add action buttons
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mListener.onDefinePathDialogPositiveClick(buildPath());
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mListener.onDefinePathDialogNegativeClick(buildPath());
|
||||
}
|
||||
});
|
||||
|
||||
// TODO Add default path
|
||||
// TODO Add intent for path selection
|
||||
|
||||
// Extension
|
||||
Spinner spinner = (Spinner) rootView.findViewById(R.id.file_types);
|
||||
spinner.setOnItemSelectedListener(this);
|
||||
|
||||
// Spinner Drop down elements
|
||||
String[] fileTypes = getResources().getStringArray(R.array.file_types);
|
||||
ArrayAdapter<String> dataAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, fileTypes);
|
||||
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spinner.setAdapter(dataAdapter);
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
|
||||
String item = adapterView.getItemAtPosition(position).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
|
||||
}
|
||||
|
||||
private Uri buildPath() {
|
||||
// TODO Correct path
|
||||
TextView folderPath = (TextView) rootView.findViewById(R.id.folder_path);
|
||||
TextView filename = (TextView) rootView.findViewById(R.id.filename);
|
||||
|
||||
|
||||
Uri path = new Uri.Builder().path(folderPath.getText().toString())
|
||||
.appendPath(filename.getText().toString()).build();
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,6 +51,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.keepassdroid.AssignPasswordDialog;
|
||||
import com.keepassdroid.CreateFileDialog;
|
||||
import com.keepassdroid.GroupActivity;
|
||||
import com.keepassdroid.PasswordActivity;
|
||||
import com.keepassdroid.ProgressTask;
|
||||
@@ -77,6 +78,7 @@ import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
public class FileSelectActivity extends StylishActivity implements
|
||||
CreateFileDialog.DefinePathDialogListener ,
|
||||
AssignPasswordDialog.AssignPasswordDialogListener {
|
||||
|
||||
private static final int MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE = 111;
|
||||
@@ -152,8 +154,8 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
createButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
public void onClick(View v) {
|
||||
AssignPasswordDialog assignPasswordDialog = new AssignPasswordDialog();
|
||||
assignPasswordDialog.show(getSupportFragmentManager(), "passwordDialog");
|
||||
CreateFileDialog createFileDialog = new CreateFileDialog();
|
||||
createFileDialog.show(getSupportFragmentManager(), "createFileDialog");
|
||||
}
|
||||
|
||||
});
|
||||
@@ -298,6 +300,18 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDefinePathDialogPositiveClick(Uri pathFile) {
|
||||
// TODO stock path
|
||||
AssignPasswordDialog assignPasswordDialog = new AssignPasswordDialog();
|
||||
assignPasswordDialog.show(getSupportFragmentManager(), "passwordDialog");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDefinePathDialogNegativeClick(Uri pathFile) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssignKeyDialogPositiveClick(String masterPassword, Uri keyFile) {
|
||||
|
||||
@@ -332,7 +346,7 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
|
||||
}
|
||||
|
||||
private class AssignPasswordOnFinish extends FileOnFinish {
|
||||
private class AssignPasswordOnFinish extends FileOnFinish {
|
||||
|
||||
public AssignPasswordOnFinish(FileOnFinish fileOnFinish) {
|
||||
super(fileOnFinish);
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* Copyright 2017 Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePass DX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.keepassdroid.view;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -17,9 +36,6 @@ import java.io.File;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
/**
|
||||
* Created by joker on 01/12/17.
|
||||
*/
|
||||
|
||||
public class KeyFileHelper {
|
||||
|
||||
|
||||
Reference in new issue
Block a user