diff --git a/app/src/main/java/com/keepassdroid/AssignPasswordDialog.java b/app/src/main/java/com/keepassdroid/AssignPasswordDialog.java
index 09c8eefc6..5b0c0637c 100644
--- a/app/src/main/java/com/keepassdroid/AssignPasswordDialog.java
+++ b/app/src/main/java/com/keepassdroid/AssignPasswordDialog.java
@@ -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
diff --git a/app/src/main/java/com/keepassdroid/CreateFileDialog.java b/app/src/main/java/com/keepassdroid/CreateFileDialog.java
new file mode 100644
index 000000000..6249abc36
--- /dev/null
+++ b/app/src/main/java/com/keepassdroid/CreateFileDialog.java
@@ -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 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;
+ }
+
+}
diff --git a/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java b/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java
index 9e226d524..51144c742 100644
--- a/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java
+++ b/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java
@@ -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);
diff --git a/app/src/main/java/com/keepassdroid/view/KeyFileHelper.java b/app/src/main/java/com/keepassdroid/view/KeyFileHelper.java
index 00bebb761..d431e6f42 100644
--- a/app/src/main/java/com/keepassdroid/view/KeyFileHelper.java
+++ b/app/src/main/java/com/keepassdroid/view/KeyFileHelper.java
@@ -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 .
+ *
+ */
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 {
diff --git a/app/src/main/res/layout/file_creation.xml b/app/src/main/res/layout/file_creation.xml
new file mode 100644
index 000000000..b438658df
--- /dev/null
+++ b/app/src/main/res/layout/file_creation.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/file_selection_filename.xml b/app/src/main/res/layout/file_selection_filename.xml
index 87796e328..e834cc969 100644
--- a/app/src/main/res/layout/file_selection_filename.xml
+++ b/app/src/main/res/layout/file_selection_filename.xml
@@ -20,8 +20,7 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto">
Définir les caractères par défaut du générateur de mot de passe
Notifications du presse-papiers
Activer les notifications du presse-papiers pour copier le nom d\'utilisateur et le mot de passe
+ Nom de fichier
+ Chemin
+ Assigner une clé maître
+ Créer un fichier keepass
- 30 secondes
diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml
index 26180f6a0..cc2c9fbb1 100644
--- a/app/src/main/res/values/donottranslate.xml
+++ b/app/src/main/res/values/donottranslate.xml
@@ -126,4 +126,9 @@
- @string/special
- @string/brackets
+
+ New database
+
+ - .kdbx
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 42728ce2f..b7ea6f4dc 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -209,6 +209,10 @@
Set the default password generator characters
Clipboard Notifications
Enable clipboard notifications to copy username and password
+ File name
+ Path
+ Assign a master key
+ Create a keepass file
- 30 seconds
@@ -228,4 +232,5 @@
- Light Theme
- Night Theme
+