diff --git a/ReadMe.md b/ReadMe.md index c7d73a427..e6c9bce3a 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,6 +1,6 @@ # Android Keepass DX - Keepass DX is a material design Keepass Client for manage keys and passwords in crypt database for your android device. + Keepass DX is a material design Keepass Client for manage keys and passwords in crypt database for your android device. ### Features @@ -11,8 +11,8 @@ - Material design with themes - Device integration and AutoFill (In progress) - - + + ## What is KeePass? @@ -32,8 +32,8 @@ Even if the application is free, to maintain the application, you can make donat [![Donation Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/Kunzisoft/donate "Kunzisoft Liberapay Donation") - - + + ## Download diff --git a/app/build.gradle b/app/build.gradle index b71eb51d9..2cce70e09 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,14 +2,14 @@ apply plugin: 'com.android.application' android { compileSdkVersion = 26 - buildToolsVersion = "27.0.1" + buildToolsVersion = "27.0.2" defaultConfig { applicationId "com.kunzisoft.keepass" minSdkVersion 14 targetSdkVersion 26 - versionCode = 3 - versionName = "2.5.0.0beta3" + versionCode = 5 + versionName = "2.5.0.0beta5" testApplicationId = "com.keepassdroid.tests" testInstrumentationRunner = "android.test.InstrumentationTestRunner" @@ -66,6 +66,7 @@ android { def supportVersion = "26.1.0" def spongycastleVersion = "1.58.0.0" +def permissionDispatcherVersion = "3.1.0" dependencies { implementation "com.android.support:appcompat-v7:$supportVersion" @@ -75,9 +76,16 @@ dependencies { implementation "com.android.support:cardview-v7:$supportVersion" implementation "com.madgag.spongycastle:core:$spongycastleVersion" implementation "com.madgag.spongycastle:prov:$spongycastleVersion" + // Time implementation "joda-time:joda-time:2.9.9" - implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.1' - implementation group: 'com.google.guava', name: 'guava', version: '22.0-android' implementation "org.sufficientlysecure:html-textview:3.5" implementation "com.nononsenseapps:filepicker:4.1.0" + // Permissions + implementation ("com.github.hotchemi:permissionsdispatcher:$permissionDispatcherVersion") { + // if you don't use android.app.Fragment you can exclude support for them + exclude module: "support-v13" + } + annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:$permissionDispatcherVersion" + implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.1' + implementation group: 'com.google.guava', name: 'guava', version: '22.0-android' } diff --git a/app/src/androidTest/java/com/keepassdroid/tests/PwEntryTestV4.java b/app/src/androidTest/java/com/keepassdroid/tests/PwEntryTestV4.java index 2f666b3e2..73017db3c 100644 --- a/app/src/androidTest/java/com/keepassdroid/tests/PwEntryTestV4.java +++ b/app/src/androidTest/java/com/keepassdroid/tests/PwEntryTestV4.java @@ -50,7 +50,7 @@ public class PwEntryTestV4 extends TestCase { entry.icon = new PwIconStandard(5); entry.overrideURL = "override"; entry.parent = new PwGroupV4(); - entry.strings.put("key2", new ProtectedString(false, "value2")); + entry.addField("key2", new ProtectedString(false, "value2")); entry.url = "http://localhost"; entry.uuid = UUID.randomUUID(); diff --git a/app/src/androidTest/java/com/keepassdroid/tests/database/DeleteEntry.java b/app/src/androidTest/java/com/keepassdroid/tests/database/DeleteEntry.java index e45c36fea..4048b820e 100644 --- a/app/src/androidTest/java/com/keepassdroid/tests/database/DeleteEntry.java +++ b/app/src/androidTest/java/com/keepassdroid/tests/database/DeleteEntry.java @@ -24,7 +24,7 @@ import java.util.List; import android.content.Context; import android.test.AndroidTestCase; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.database.PwDatabase; import com.keepassdroid.database.PwDatabaseV3; import com.keepassdroid.database.PwEntry; @@ -74,8 +74,8 @@ public class DeleteEntry extends AndroidTestCase { PwGroup results1 = dbHelp.search(db, ENTRY1_NAME); PwGroup results2 = dbHelp.search(db, ENTRY2_NAME); - assertEquals("Entry1 was not removed from the search results", 0, results1.childEntries.size()); - assertEquals("Entry2 was not removed from the search results", 0, results2.childEntries.size()); + assertEquals("Entry1 was not removed from the search results", 0, results1.numbersOfChildEntries()); + assertEquals("Entry2 was not removed from the search results", 0, results2.numbersOfChildEntries()); // Verify the group was deleted group1 = getGroup(pm, GROUP1_NAME); diff --git a/app/src/androidTest/java/com/keepassdroid/tests/database/TestData.java b/app/src/androidTest/java/com/keepassdroid/tests/database/TestData.java index cfe702a09..b32536aa7 100644 --- a/app/src/androidTest/java/com/keepassdroid/tests/database/TestData.java +++ b/app/src/androidTest/java/com/keepassdroid/tests/database/TestData.java @@ -25,12 +25,10 @@ import android.content.Context; import android.content.res.AssetManager; import android.net.Uri; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.database.PwDatabaseV3Debug; import com.keepassdroid.database.load.Importer; import com.keepassdroid.tests.TestUtil; -import com.keepassdroid.utils.EmptyUtils; -import com.keepassdroid.utils.UriUtil; public class TestData { private static final String TEST1_KEYFILE = ""; diff --git a/app/src/androidTest/java/com/keepassdroid/tests/search/SearchTest.java b/app/src/androidTest/java/com/keepassdroid/tests/search/SearchTest.java index c57e9623d..764003e3a 100644 --- a/app/src/androidTest/java/com/keepassdroid/tests/search/SearchTest.java +++ b/app/src/androidTest/java/com/keepassdroid/tests/search/SearchTest.java @@ -26,7 +26,7 @@ import android.preference.PreferenceManager; import android.test.AndroidTestCase; import com.kunzisoft.keepass.R; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.database.PwGroup; import com.keepassdroid.tests.database.TestData; @@ -43,7 +43,7 @@ public class SearchTest extends AndroidTestCase { public void testSearch() { PwGroup results = mDb.Search("Amazon"); - assertTrue("Search result not found.", results.childEntries.size() > 0); + assertTrue("Search result not found.", results.numbersOfChildEntries() > 0); } @@ -51,14 +51,14 @@ public class SearchTest extends AndroidTestCase { updateOmitSetting(false); PwGroup results = mDb.Search("BackupOnly"); - assertTrue("Search result not found.", results.childEntries.size() > 0); + assertTrue("Search result not found.", results.numbersOfChildEntries() > 0); } public void testBackupExcluded() { updateOmitSetting(true); PwGroup results = mDb.Search("BackupOnly"); - assertFalse("Search result found, but should not have been.", results.childEntries.size() > 0); + assertFalse("Search result found, but should not have been.", results.numbersOfChildEntries() > 0); } private void updateOmitSetting(boolean setting) { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3dc05ddf5..2a30bcd54 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,8 +23,9 @@ android:theme="@style/KeepassDXStyle.Light" tools:replace="android:theme"> - + @@ -52,15 +53,19 @@ - - - + @@ -90,38 +95,40 @@ - - - - - - + + + + + + + + + - - + android:name="com.keepassdroid.search.SearchResultsActivity" + android:launchMode="standard"> - + . - * - */ -package com.keepassdroid; - -import java.util.Map; - -import android.view.View; -import android.view.ViewGroup; - -import com.kunzisoft.keepass.R; -import com.keepassdroid.app.App; -import com.keepassdroid.database.PwDatabase; -import com.keepassdroid.database.PwEntryV4; -import com.keepassdroid.database.security.ProtectedString; -import com.keepassdroid.utils.SprEngine; -import com.keepassdroid.utils.SprEngineV4; -import com.keepassdroid.view.EntrySection; - - -public class EntryActivityV4 extends EntryActivity { - - @Override - protected void setEntryView() { - setContentView(R.layout.entry_view); - } - - @Override - protected void fillData(boolean trimList) { - super.fillData(trimList); - - ViewGroup group = (ViewGroup) findViewById(R.id.extra_strings); - - if (trimList) { - group.removeAllViews(); - } - - PwEntryV4 entry = (PwEntryV4) mEntry; - - PwDatabase pm = App.getDB().pm; - SprEngine spr = SprEngineV4.getInstance(pm); - - // Display custom strings - if (entry.strings.size() > 0) { - for (Map.Entry pair : entry.strings.entrySet()) { - String key = pair.getKey(); - - if (!PwEntryV4.IsStandardString(key)) { - String text = pair.getValue().toString(); - View view = new EntrySection(this, null, key, spr.compile(text, entry, pm)); - group.addView(view); - } - } - } - - } - - -} diff --git a/app/src/main/java/com/keepassdroid/EntryEditActivity.java b/app/src/main/java/com/keepassdroid/EntryEditActivity.java deleted file mode 100644 index d05fc2cff..000000000 --- a/app/src/main/java/com/keepassdroid/EntryEditActivity.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.support.v7.widget.Toolbar; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.EditText; -import android.widget.ImageButton; -import android.widget.TextView; -import android.widget.Toast; - -import com.kunzisoft.keepass.KeePass; -import com.kunzisoft.keepass.R; -import com.keepassdroid.app.App; -import com.keepassdroid.database.PwDatabase; -import com.keepassdroid.database.PwEntry; -import com.keepassdroid.database.PwEntryV3; -import com.keepassdroid.database.PwEntryV4; -import com.keepassdroid.database.PwGroup; -import com.keepassdroid.database.PwGroupId; -import com.keepassdroid.database.PwGroupV3; -import com.keepassdroid.database.PwGroupV4; -import com.keepassdroid.database.PwIconStandard; -import com.keepassdroid.database.edit.AddEntry; -import com.keepassdroid.database.edit.OnFinish; -import com.keepassdroid.database.edit.RunnableOnFinish; -import com.keepassdroid.database.edit.UpdateEntry; -import com.keepassdroid.icons.Icons; -import com.keepassdroid.utils.MenuUtil; -import com.keepassdroid.utils.Types; -import com.keepassdroid.utils.Util; - -import java.util.Calendar; -import java.util.Date; -import java.util.UUID; - -public abstract class EntryEditActivity extends LockCloseHideActivity - implements IconPickerFragment.IconPickerListener, - GeneratePasswordFragment.GeneratePasswordListener { - public static final String KEY_ENTRY = "entry"; - public static final String KEY_PARENT = "parent"; - - protected PwEntry mEntry; - protected boolean mIsNew; - protected int mSelectedIconID = -1; - - public static void Launch(Activity act, PwEntry pw) { - Intent i; - if (pw instanceof PwEntryV3) { - i = new Intent(act, EntryEditActivityV3.class); - } - else if (pw instanceof PwEntryV4) { - i = new Intent(act, EntryEditActivityV4.class); - } - else { - throw new RuntimeException("Not yet implemented."); - } - - i.putExtra(KEY_ENTRY, Types.UUIDtoBytes(pw.getUUID())); - - act.startActivityForResult(i, 0); - } - - public static void Launch(Activity act, PwGroup pw) { - Intent i; - if (pw instanceof PwGroupV3) { - i = new Intent(act, EntryEditActivityV3.class); - EntryEditActivityV3.putParentId(i, KEY_PARENT, (PwGroupV3)pw); - } - else if (pw instanceof PwGroupV4) { - i = new Intent(act, EntryEditActivityV4.class); - EntryEditActivityV4.putParentId(i, KEY_PARENT, (PwGroupV4)pw); - } - else { - throw new RuntimeException("Not yet implemented."); - } - - act.startActivityForResult(i, 0); - } - - protected abstract PwGroupId getParentGroupId(Intent i, String key); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.entry_edit); - setResult(KeePass.EXIT_NORMAL); - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - toolbar.setTitle(getString(R.string.app_name)); - setSupportActionBar(toolbar); - assert getSupportActionBar() != null; - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setDisplayShowHomeEnabled(true); - - // Likely the app has been killed exit the activity - Database db = App.getDB(); - if ( ! db.Loaded() ) { - finish(); - return; - } - - Intent i = getIntent(); - byte[] uuidBytes = i.getByteArrayExtra(KEY_ENTRY); - - PwDatabase pm = db.pm; - if ( uuidBytes == null ) { - - PwGroupId parentId = getParentGroupId(i, KEY_PARENT); - PwGroup parent = pm.groups.get(parentId); - mEntry = PwEntry.getInstance(parent); - mIsNew = true; - - } else { - UUID uuid = Types.bytestoUUID(uuidBytes); - mEntry = pm.entries.get(uuid); - mIsNew = false; - fillData(); - } - - View scrollView = findViewById(R.id.entry_scroll); - scrollView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); - - View iconButton = findViewById(R.id.icon_button); - iconButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - IconPickerFragment.Launch(EntryEditActivity.this); - } - }); - - // Generate password button - View generatePassword = findViewById(R.id.generate_button); - generatePassword.setOnClickListener(new OnClickListener() { - - public void onClick(View v) { - GeneratePasswordFragment generatePasswordFragment = new GeneratePasswordFragment(); - generatePasswordFragment.show(getSupportFragmentManager(), "PasswordGeneratorFragment"); - } - }); - - // Save button - View save = findViewById(R.id.entry_save); - save.setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - EntryEditActivity act = EntryEditActivity.this; - - if (!validateBeforeSaving()) { - return; - } - - PwEntry newEntry = populateNewEntry(); - - if ( newEntry.getTitle().equals(mEntry.getTitle()) ) { - setResult(KeePass.EXIT_REFRESH); - } else { - setResult(KeePass.EXIT_REFRESH_TITLE); - } - - RunnableOnFinish task; - OnFinish onFinish = act.new AfterSave(new Handler()); - - if ( mIsNew ) { - task = AddEntry.getInstance(EntryEditActivity.this, App.getDB(), newEntry, onFinish); - } else { - task = new UpdateEntry(EntryEditActivity.this, App.getDB(), mEntry, newEntry, onFinish); - } - ProgressTask pt = new ProgressTask(act, task, R.string.saving_database); - pt.run(); - } - - }); - } - - protected boolean validateBeforeSaving() { - // Require title - String title = Util.getEditText(this, R.id.entry_title); - if ( title.length() == 0 ) { - Toast.makeText(this, R.string.error_title_required, Toast.LENGTH_LONG).show(); - return false; - } - - // Validate password - String pass = Util.getEditText(this, R.id.entry_password); - String conf = Util.getEditText(this, R.id.entry_confpassword); - if ( ! pass.equals(conf) ) { - Toast.makeText(this, R.string.error_pass_match, Toast.LENGTH_LONG).show(); - return false; - } - - return true; - } - - protected PwEntry populateNewEntry() { - return populateNewEntry(null); - } - - protected PwEntry populateNewEntry(PwEntry entry) { - PwEntry newEntry; - if (entry == null) { - newEntry = mEntry.clone(true); - } - else { - newEntry = entry; - } - - Date now = Calendar.getInstance().getTime(); - newEntry.setLastAccessTime(now); - newEntry.setLastModificationTime(now); - - PwDatabase db = App.getDB().pm; - newEntry.setTitle(Util.getEditText(this, R.id.entry_title), db); - if(mSelectedIconID != -1) - newEntry.setIcon(new PwIconStandard(mSelectedIconID)); - newEntry.setUrl(Util.getEditText(this, R.id.entry_url), db); - newEntry.setUsername(Util.getEditText(this, R.id.entry_user_name), db); - newEntry.setNotes(Util.getEditText(this, R.id.entry_comment), db); - newEntry.setPassword(Util.getEditText(this, R.id.entry_password), db); - - return newEntry; - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - - MenuInflater inflater = getMenuInflater(); - MenuUtil.donationMenuInflater(inflater, menu); - - return true; - } - - public boolean onOptionsItemSelected(MenuItem item) { - switch ( item.getItemId() ) { - case R.id.menu_donate: - return MenuUtil.onDonationItemSelected(this); - - case android.R.id.home: - finish(); - } - - return super.onOptionsItemSelected(item); - } - - protected void fillData() { - ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button); - App.getDB().drawFactory.assignDrawableTo(currIconButton, getResources(), mEntry.getIcon()); - - populateText(R.id.entry_title, mEntry.getTitle()); - populateText(R.id.entry_user_name, mEntry.getUsername()); - populateText(R.id.entry_url, mEntry.getUrl()); - - String password = mEntry.getPassword(); - populateText(R.id.entry_password, password); - populateText(R.id.entry_confpassword, password); - - populateText(R.id.entry_comment, mEntry.getNotes()); - } - - private void populateText(int viewId, String text) { - TextView tv = (TextView) findViewById(viewId); - tv.setText(text); - } - - @Override - public void iconPicked(Bundle bundle) { - mSelectedIconID = bundle.getInt(IconPickerFragment.KEY_ICON_ID); - ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button); - currIconButton.setImageResource(Icons.iconToResId(mSelectedIconID)); - } - - @Override - public void acceptPassword(Bundle bundle) { - String generatedPassword = bundle.getString(GeneratePasswordFragment.KEY_PASSWORD_ID); - EditText password = (EditText) findViewById(R.id.entry_password); - EditText confPassword = (EditText) findViewById(R.id.entry_confpassword); - - password.setText(generatedPassword); - confPassword.setText(generatedPassword); - } - - @Override - public void cancelPassword(Bundle bundle) { - // Do nothing here - } - - private final class AfterSave extends OnFinish { - - AfterSave(Handler handler) { - super(handler); - } - - @Override - public void run() { - if ( mSuccess ) { - finish(); - } else { - displayMessage(EntryEditActivity.this); - } - } - } - -} diff --git a/app/src/main/java/com/keepassdroid/EntryEditActivityV3.java b/app/src/main/java/com/keepassdroid/EntryEditActivityV3.java deleted file mode 100644 index 3bb54bfc4..000000000 --- a/app/src/main/java/com/keepassdroid/EntryEditActivityV3.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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; - -import android.content.Intent; - -import com.keepassdroid.app.App; -import com.keepassdroid.database.PwEntry; -import com.keepassdroid.database.PwGroupId; -import com.keepassdroid.database.PwGroupIdV3; -import com.keepassdroid.database.PwGroupV3; - -public class EntryEditActivityV3 extends EntryEditActivity { - - @Override - protected PwEntry populateNewEntry(PwEntry entry) { - PwEntry newEntry = super.populateNewEntry(entry); - - if (mSelectedIconID == -1) { - if (mIsNew) { - newEntry.icon = App.getDB().pm.iconFactory.getIcon(0); - } - else { - // Keep previous icon, if no new one was selected - newEntry.icon = mEntry.icon; - } - } - else { - newEntry.icon = App.getDB().pm.iconFactory.getIcon(mSelectedIconID); - } - - return newEntry; - } - - protected static void putParentId(Intent i, String parentKey, PwGroupV3 parent) { - i.putExtra(parentKey, parent.groupId); - } - - @Override - protected PwGroupId getParentGroupId(Intent i, String key) { - int groupId = i.getIntExtra(key, -1); - - return new PwGroupIdV3(groupId); - } -} diff --git a/app/src/main/java/com/keepassdroid/EntryEditActivityV4.java b/app/src/main/java/com/keepassdroid/EntryEditActivityV4.java deleted file mode 100644 index e3dce1cf3..000000000 --- a/app/src/main/java/com/keepassdroid/EntryEditActivityV4.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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; - -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.CheckBox; -import android.widget.LinearLayout; -import android.widget.ScrollView; -import android.widget.TextView; -import android.widget.Toast; - -import com.kunzisoft.keepass.R; -import com.keepassdroid.app.App; -import com.keepassdroid.database.PwDatabaseV4; -import com.keepassdroid.database.PwEntry; -import com.keepassdroid.database.PwEntryV4; -import com.keepassdroid.database.PwGroupId; -import com.keepassdroid.database.PwGroupIdV4; -import com.keepassdroid.database.PwGroupV4; -import com.keepassdroid.database.security.ProtectedString; -import com.keepassdroid.utils.Types; -import com.keepassdroid.view.EntryEditSection; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; - -public class EntryEditActivityV4 extends EntryEditActivity { - - private ScrollView scroll; - private LayoutInflater inflater; - - protected static void putParentId(Intent i, String parentKey, PwGroupV4 parent) { - PwGroupId id = parent.getId(); - PwGroupIdV4 id4 = (PwGroupIdV4) id; - - i.putExtra(parentKey, Types.UUIDtoBytes(id4.getId())); - - } - - @Override - protected PwGroupId getParentGroupId(Intent i, String key) { - byte[] buf = i.getByteArrayExtra(key); - UUID id = Types.bytestoUUID(buf); - - return new PwGroupIdV4(id); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - - super.onCreate(savedInstanceState); - - scroll = (ScrollView) findViewById(R.id.entry_scroll); - - View add = findViewById(R.id.add_advanced); - add.setVisibility(View.VISIBLE); - add.setOnClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - LinearLayout container = (LinearLayout) findViewById(R.id.advanced_container); - - EntryEditSection ees = (EntryEditSection) inflater.inflate(R.layout.entry_edit_section, container, false); - ees.setData("", new ProtectedString(false, "")); - container.addView(ees); - - // Scroll bottom - scroll.post(new Runnable() { - @Override - public void run() { - scroll.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - - } - }); - - } - - @Override - protected void fillData() { - super.fillData(); - - PwEntryV4 entry = (PwEntryV4) mEntry; - - LinearLayout container = (LinearLayout) findViewById(R.id.advanced_container); - - if (entry.strings.size() > 0) { - for (Entry pair : entry.strings.entrySet()) { - String key = pair.getKey(); - - if (!PwEntryV4.IsStandardString(key)) { - EntryEditSection ees = (EntryEditSection) inflater.inflate(R.layout.entry_edit_section, container, false); - ees.setData(key, pair.getValue()); - container.addView(ees); - } - } - - } - - } - - @SuppressWarnings("unchecked") - @Override - protected PwEntry populateNewEntry() { - PwEntryV4 newEntry = (PwEntryV4) mEntry.clone(true); - newEntry.history = (ArrayList) newEntry.history.clone(); - newEntry.createBackup((PwDatabaseV4)App.getDB().pm); - - newEntry = (PwEntryV4) super.populateNewEntry(newEntry); - - Map strings = newEntry.strings; - - // Delete all new standard strings - Iterator> iter = strings.entrySet().iterator(); - while (iter.hasNext()) { - Entry pair = iter.next(); - if (!PwEntryV4.IsStandardString(pair.getKey())) { - iter.remove(); - } - } - - LinearLayout container = (LinearLayout) findViewById(R.id.advanced_container); - for (int i = 0; i < container.getChildCount(); i++) { - View view = container.getChildAt(i); - - TextView keyView = (TextView)view.findViewById(R.id.title); - String key = keyView.getText().toString(); - - TextView valueView = (TextView)view.findViewById(R.id.value); - String value = valueView.getText().toString(); - - CheckBox cb = (CheckBox)view.findViewById(R.id.protection); - boolean protect = cb.isChecked(); - - strings.put(key, new ProtectedString(protect, value)); - } - - return newEntry; - } - - public void deleteAdvancedString(View view) { - ViewGroup section = (ViewGroup) view.getParent(); - LinearLayout container = (LinearLayout) findViewById(R.id.advanced_container); - - for (int i = 0; i < container.getChildCount(); i++) { - ViewGroup ees = (ViewGroup) container.getChildAt(i); - if (ees == section) { - container.removeViewAt(i); - container.invalidate(); - break; - } - } - } - - @Override - protected boolean validateBeforeSaving() { - if(!super.validateBeforeSaving()) { - return false; - } - - LinearLayout container = (LinearLayout) findViewById(R.id.advanced_container); - for (int i = 0; i < container.getChildCount(); i++) { - EntryEditSection ees = (EntryEditSection) container.getChildAt(i); - - TextView keyView = (TextView) ees.findViewById(R.id.title); - CharSequence key = keyView.getText(); - - if (key == null || key.length() == 0) { - Toast.makeText(this, R.string.error_string_key, Toast.LENGTH_LONG).show(); - return false; - } - - } - - return true; - } - -} - \ No newline at end of file diff --git a/app/src/main/java/com/keepassdroid/GroupActivity.java b/app/src/main/java/com/keepassdroid/GroupActivity.java deleted file mode 100644 index e8dc6354d..000000000 --- a/app/src/main/java/com/keepassdroid/GroupActivity.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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; - -import android.app.Activity; -import android.app.Dialog; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.preference.PreferenceManager; -import android.support.v7.widget.Toolbar; -import android.util.Log; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView.AdapterContextMenuInfo; - -import com.keepassdroid.app.App; -import com.keepassdroid.autofill.AutofillHelper; -import com.keepassdroid.database.PwDatabase; -import com.keepassdroid.database.PwDatabaseV3; -import com.keepassdroid.database.PwDatabaseV4; -import com.keepassdroid.database.PwGroup; -import com.keepassdroid.database.PwGroupId; -import com.keepassdroid.database.PwGroupV3; -import com.keepassdroid.database.PwGroupV4; -import com.keepassdroid.database.edit.AddGroup; -import com.keepassdroid.dialog.ReadOnlyDialog; -import com.keepassdroid.view.ClickView; -import com.keepassdroid.view.GroupAddEntryView; -import com.keepassdroid.view.GroupRootView; -import com.keepassdroid.view.GroupViewOnlyView; -import com.kunzisoft.keepass.KeePass; -import com.kunzisoft.keepass.R; - -public abstract class GroupActivity extends GroupBaseActivity - implements GroupEditFragment.CreateGroupListener, IconPickerFragment.IconPickerListener { - - private static final String TAG_CREATE_GROUP = "TAG_CREATE_GROUP"; - - protected boolean addGroupEnabled = false; - protected boolean addEntryEnabled = false; - protected boolean isRoot = false; - protected boolean readOnly = false; - - private static final String TAG = "Group Activity:"; - - public static void Launch(Activity act) { - Launch(act, null, null); - } - - public static void Launch(Activity act, Bundle extras) { - Launch(act, null, extras); - } - - public static void Launch(Activity act, PwGroup group) { - Launch(act, group, null); - } - - public static void Launch(Activity act, PwGroup group, Bundle extras) { - Intent intent; - - // Need to use PwDatabase since tree may be null - PwDatabase db = App.getDB().pm; - if ( db instanceof PwDatabaseV3 ) { - intent = new Intent(act, GroupActivityV3.class); - - if ( group != null ) { - PwGroupV3 g = (PwGroupV3) group; - intent.putExtra(KEY_ENTRY, g.groupId); - } - } else if ( db instanceof PwDatabaseV4 ) { - intent = new Intent(act, GroupActivityV4.class); - - if ( group != null ) { - PwGroupV4 g = (PwGroupV4) group; - intent.putExtra(KEY_ENTRY, g.uuid.toString()); - } - } else { - // Reached if db is null - Log.d(TAG, "Tried to launch with null db"); - return; - } - if (extras != null) - intent.putExtras(extras); - act.startActivityForResult(intent,0); - } - - protected abstract PwGroupId retrieveGroupId(Intent i); - - protected void setupButtons() { - addGroupEnabled = !readOnly; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (isFinishing()) { - return; - } - - setResult(KeePass.EXIT_NORMAL); - - Log.w(TAG, "Creating tree view"); - Intent intent = getIntent(); - - PwGroupId id = retrieveGroupId(intent); - - Database db = App.getDB(); - - // Force readonly if it's autofill - readOnly = AutofillHelper.isIntentContainsAutofillAuthKey(getIntent()) || db.readOnly; - - PwGroup root = db.pm.rootGroup; - if (id == null) { - mGroup = root; - } else { - mGroup = db.pm.groups.get(id); - } - - Log.w(TAG, "Retrieved tree"); - if (mGroup == null) { - Log.w(TAG, "Group was null"); - return; - } - - isRoot = mGroup == root; - - setupButtons(); - - if (addGroupEnabled && addEntryEnabled) { - setContentView(new GroupAddEntryView(this)); - } else if (addGroupEnabled) { - setContentView(new GroupRootView(this)); - View addEntry = findViewById(R.id.add_entry); - addEntry.setVisibility(View.GONE); - } else if (addEntryEnabled) { - setContentView(new GroupAddEntryView(this)); - View addGroup = findViewById(R.id.add_group); - addGroup.setVisibility(View.GONE); - } else { - setContentView(new GroupViewOnlyView(this)); - } - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - toolbar.setTitle(""); - setSupportActionBar(toolbar); - - if (mGroup.getParent() != null) - toolbar.setNavigationIcon(R.drawable.ic_arrow_up_white_24dp); - - Log.w(TAG, "Set view"); - - if (addGroupEnabled) { - // Add Group button - View addGroup = findViewById(R.id.add_group); - addGroup.setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - GroupEditFragment groupEditFragment = new GroupEditFragment(); - groupEditFragment.show(getSupportFragmentManager(), TAG_CREATE_GROUP); - } - }); - } - - if (addEntryEnabled) { - // Add Entry button - View addEntry = findViewById(R.id.add_entry); - addEntry.setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - EntryEditActivity.Launch(GroupActivity.this, mGroup); - } - }); - } - - setGroupTitle(); - setGroupIcon(); - - setListAdapter(new PwGroupListAdapter(this, mGroup)); - registerForContextMenu(getListView()); - Log.w(TAG, "Finished creating tree"); - - if (isRoot) { - showWarnings(); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - } - return super.onOptionsItemSelected(item); - } - - @Override - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenuInfo menuInfo) { - - AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo; - ClickView cv = (ClickView) acmi.targetView; - cv.onCreateMenu(menu, menuInfo); - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) item.getMenuInfo(); - ClickView cv = (ClickView) acmi.targetView; - - return cv.onContextItemSelected(item); - } - - @Override - public void approveCreateGroup(Bundle bundle) { - String GroupName = bundle.getString(GroupEditFragment.KEY_NAME); - int GroupIconID = bundle.getInt(GroupEditFragment.KEY_ICON_ID); - GroupActivity act = GroupActivity.this; - Handler handler = new Handler(); - AddGroup task = AddGroup.getInstance(this, App.getDB(), GroupName, GroupIconID, mGroup, act.new RefreshTask(handler), false); - ProgressTask pt = new ProgressTask(act, task, R.string.saving_database); - pt.run(); - } - - @Override - public void cancelCreateGroup(Bundle bundle) { - // Do nothing here - } - - @Override - // For icon in create tree dialog - public void iconPicked(Bundle bundle) { - GroupEditFragment groupEditFragment = (GroupEditFragment) getSupportFragmentManager().findFragmentByTag(TAG_CREATE_GROUP); - if (groupEditFragment != null) { - groupEditFragment.iconPicked(bundle); - } - } - - protected void showWarnings() { - if (App.getDB().readOnly) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - - if (prefs.getBoolean(getString(R.string.show_read_only_warning), true)) { - Dialog dialog = new ReadOnlyDialog(this); - dialog.show(); - } - } - } -} diff --git a/app/src/main/java/com/keepassdroid/GroupActivityV3.java b/app/src/main/java/com/keepassdroid/GroupActivityV3.java deleted file mode 100644 index ed296c0c8..000000000 --- a/app/src/main/java/com/keepassdroid/GroupActivityV3.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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; - -import android.content.Intent; - -import com.keepassdroid.database.PwGroupIdV3; - -public class GroupActivityV3 extends GroupActivity { - - @Override - protected PwGroupIdV3 retrieveGroupId(Intent i) { - int id = i.getIntExtra(KEY_ENTRY, -1); - - if ( id == -1 ) { - return null; - } - - return new PwGroupIdV3(id); - } - - @Override - protected void setupButtons() { - super.setupButtons(); - addEntryEnabled = !isRoot && !readOnly; - } -} diff --git a/app/src/main/java/com/keepassdroid/GroupActivityV4.java b/app/src/main/java/com/keepassdroid/GroupActivityV4.java deleted file mode 100644 index 216d38b89..000000000 --- a/app/src/main/java/com/keepassdroid/GroupActivityV4.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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; - -import java.util.UUID; - -import android.content.Intent; - -import com.keepassdroid.database.PwGroupId; -import com.keepassdroid.database.PwGroupIdV4; - -public class GroupActivityV4 extends GroupActivity { - - @Override - protected PwGroupId retrieveGroupId(Intent i) { - String uuid = i.getStringExtra(KEY_ENTRY); - - if ( uuid == null || uuid.length() == 0 ) { - return null; - } - - return new PwGroupIdV4(UUID.fromString(uuid)); - } - - @Override - protected void setupButtons() { - super.setupButtons(); - addEntryEnabled = !readOnly; - } -} diff --git a/app/src/main/java/com/keepassdroid/GroupBaseActivity.java b/app/src/main/java/com/keepassdroid/GroupBaseActivity.java deleted file mode 100644 index b5bda2951..000000000 --- a/app/src/main/java/com/keepassdroid/GroupBaseActivity.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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; - -import android.app.SearchManager; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.os.Build; -import android.net.Uri; -import android.os.Bundle; -import android.os.Handler; -import android.preference.PreferenceManager; -import android.support.v7.widget.SearchView; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.ListAdapter; -import android.widget.ListView; -import android.widget.TextView; - -import com.keepassdroid.app.App; -import com.keepassdroid.compat.ActivityCompat; -import com.keepassdroid.compat.EditorCompat; -import com.keepassdroid.database.PwGroup; -import com.keepassdroid.database.edit.OnFinish; -import com.keepassdroid.search.SearchResultsActivity; -import com.keepassdroid.utils.MenuUtil; -import com.keepassdroid.view.AssignPasswordHelper; -import com.keepassdroid.view.ClickView; -import com.keepassdroid.view.GroupViewOnlyView; -import com.kunzisoft.keepass.KeePass; -import com.kunzisoft.keepass.R; - -public abstract class GroupBaseActivity extends LockCloseListActivity - implements AssignMasterKeyDialog.AssignPasswordDialogListener { - protected ListView mList; - protected ListAdapter mAdapter; - - public static final String KEY_ENTRY = "entry"; - - private SharedPreferences prefs; - - protected PwGroup mGroup; - - @Override - protected void onResume() { - super.onResume(); - - refreshIfDirty(); - } - - public void refreshIfDirty() { - Database db = App.getDB(); - if ( db.dirty.contains(mGroup) ) { - db.dirty.remove(mGroup); - ((BaseAdapter) mAdapter).notifyDataSetChanged(); - } - } - - protected void onListItemClick(ListView l, View v, int position, long id) { - ClickView cv = (ClickView) mAdapter.getView(position, null, null); - cv.onClick(); - - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Likely the app has been killed exit the activity - if ( ! App.getDB().Loaded() ) { - finish(); - return; - } - - prefs = PreferenceManager.getDefaultSharedPreferences(this); - - ActivityCompat.invalidateOptionsMenu(this); - - setContentView(new GroupViewOnlyView(this)); - setResult(KeePass.EXIT_NORMAL); - - styleScrollBars(); - - } - - protected void styleScrollBars() { - ensureCorrectListView(); - mList.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); - mList.setTextFilterEnabled(true); - - } - - protected void setGroupTitle() { - if ( mGroup != null ) { - String name = mGroup.getName(); - TextView tv = (TextView) findViewById(R.id.group_name); - if ( name != null && name.length() > 0 ) { - if ( tv != null ) { - tv.setText(name); - } - } else { - if ( tv != null ) { - tv.setText(getText(R.string.root)); - } - - } - } - } - - protected void setGroupIcon() { - if (mGroup != null) { - ImageView iv = (ImageView) findViewById(R.id.icon); - App.getDB().drawFactory.assignDrawableTo(iv, getResources(), mGroup.getIcon()); - } - } - - protected void setListAdapter(ListAdapter adapter) { - ensureCorrectListView(); - mAdapter = adapter; - mList.setAdapter(adapter); - } - - protected ListView getListView() { - ensureCorrectListView(); - return mList; - } - - private void ensureCorrectListView(){ - mList = (ListView)findViewById(R.id.group_list); - if (mList != null) { - mList.setOnItemClickListener( - new AdapterView.OnItemClickListener() { - public void onItemClick(AdapterView parent, View v, int position, long id) { - onListItemClick((ListView) parent, v, position, id); - } - } - ); - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.search, menu); - MenuUtil.donationMenuInflater(inflater, menu); - inflater.inflate(R.menu.tree, menu); - inflater.inflate(R.menu.database, menu); - inflater.inflate(R.menu.default_menu, menu); - - // Get the SearchView and set the searchable configuration - SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); - assert searchManager != null; - - MenuItem searchItem = menu.findItem(R.id.menu_search); - SearchView searchView = null; - if (searchItem != null) { - searchView = (SearchView) searchItem.getActionView(); - } - if (searchView != null) { - searchView.setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(this, SearchResultsActivity.class))); - searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default - } - - return true; - } - - private void setSortMenuText(Menu menu) { - boolean sortByName = false; - - // Will be null if onPrepareOptionsMenu is called before onCreate - if (prefs != null) { - sortByName = prefs.getBoolean(getString(R.string.sort_key), getResources().getBoolean(R.bool.sort_default)); - } - - int resId; - if ( sortByName ) { - resId = R.string.sort_db; - } else { - resId = R.string.sort_name; - } - - menu.findItem(R.id.menu_sort).setTitle(resId); - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - if ( ! super.onPrepareOptionsMenu(menu) ) { - return false; - } - - setSortMenuText(menu); - - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch ( item.getItemId() ) { - - case R.id.menu_search: - onSearchRequested(); - return true; - - case R.id.menu_sort: - toggleSort(); - return true; - - case R.id.menu_lock: - App.setShutdown(); - setResult(KeePass.EXIT_LOCK); - finish(); - return true; - - case R.id.menu_change_master_key: - setPassword(); - return true; - - default: - MenuUtil.onDefaultMenuOptionsItemSelected(this, item); - return super.onOptionsItemSelected(item); - } - } - - private void toggleSort() { - // Toggle setting - String sortKey = getString(R.string.sort_key); - boolean sortByName = prefs.getBoolean(sortKey, getResources().getBoolean(R.bool.sort_default)); - Editor editor = prefs.edit(); - editor.putBoolean(sortKey, ! sortByName); - EditorCompat.apply(editor); - - // Refresh menu titles - ActivityCompat.invalidateOptionsMenu(this); - - // Mark all groups as dirty now to refresh them on load - Database db = App.getDB(); - db.markAllGroupsAsDirty(); - // We'll manually refresh this tree so we can remove it - db.dirty.remove(mGroup); - - // Tell the adapter to refresh it's list - ((BaseAdapter) mAdapter).notifyDataSetChanged(); - - } - - @Override - public void onAssignKeyDialogPositiveClick( - boolean masterPasswordChecked, String masterPassword, - boolean keyFileChecked, Uri keyFile) { - - AssignPasswordHelper assignPasswordHelper = - new AssignPasswordHelper(this, - masterPassword, keyFile); - assignPasswordHelper.assignPasswordInDatabase(null); - } - - @Override - public void onAssignKeyDialogNegativeClick( - boolean masterPasswordChecked, String masterPassword, - boolean keyFileChecked, Uri keyFile) { - - } - - private void setPassword() { - AssignMasterKeyDialog dialog = new AssignMasterKeyDialog(); - dialog.show(getSupportFragmentManager(), "passwordDialog"); - } - - public class RefreshTask extends OnFinish { - public RefreshTask(Handler handler) { - super(handler); - } - - @Override - public void run() { - if ( mSuccess) { - refreshIfDirty(); - } else { - displayMessage(GroupBaseActivity.this); - } - } - } - - @Override - public void startActivityForResult(Intent intent, int requestCode, Bundle options) { - /* - * ACTION_SEARCH automatically forces a new task. This occurs when you open a kdb file in - * another app such as Files or GoogleDrive and then Search for an entry. Here we remove the - * FLAG_ACTIVITY_NEW_TASK flag bit allowing search to open it's activity in the current task. - */ - if (Intent.ACTION_SEARCH.equals(intent.getAction())) { - int flags = intent.getFlags(); - flags &= ~Intent.FLAG_ACTIVITY_NEW_TASK; - intent.setFlags(flags); - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - super.startActivityForResult(intent, requestCode, options); - } - } - - public class AfterDeleteGroup extends OnFinish { - public AfterDeleteGroup(Handler handler) { - super(handler); - } - - @Override - public void run() { - if ( mSuccess) { - refreshIfDirty(); - } else { - mHandler.post(new UIToastTask(GroupBaseActivity.this, "Unrecoverable error: " + mMessage)); - App.setShutdown(); - finish(); - } - } - } -} diff --git a/app/src/main/java/com/keepassdroid/PwGroupListAdapter.java b/app/src/main/java/com/keepassdroid/PwGroupListAdapter.java deleted file mode 100644 index 1e4f8379b..000000000 --- a/app/src/main/java/com/keepassdroid/PwGroupListAdapter.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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; - -import android.content.SharedPreferences; -import android.preference.PreferenceManager; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; - -import com.keepassdroid.database.PwEntry; -import com.keepassdroid.database.PwGroup; -import com.keepassdroid.view.PwEntryView; -import com.keepassdroid.view.PwGroupView; -import com.kunzisoft.keepass.R; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class PwGroupListAdapter extends BaseAdapter { - - private GroupBaseActivity mAct; - private PwGroup mGroup; - private List groupsForViewing; - private List entriesForViewing; - private Comparator entryComp = new PwEntry.EntryNameComparator(); - private Comparator groupComp = new PwGroup.GroupNameComparator(); - private SharedPreferences prefs; - - public PwGroupListAdapter(GroupBaseActivity act, PwGroup group) { - mAct = act; - mGroup = group; - prefs = PreferenceManager.getDefaultSharedPreferences(act); - - filterAndSort(); - - } - - @Override - public void notifyDataSetChanged() { - super.notifyDataSetChanged(); - - filterAndSort(); - } - - @Override - public void notifyDataSetInvalidated() { - super.notifyDataSetInvalidated(); - - filterAndSort(); - } - - private void filterAndSort() { - entriesForViewing = new ArrayList(); - - for (int i = 0; i < mGroup.childEntries.size(); i++) { - PwEntry entry = mGroup.childEntries.get(i); - if ( ! entry.isMetaStream() ) { - entriesForViewing.add(entry); - } - } - - boolean sortLists = prefs.getBoolean(mAct.getString(R.string.sort_key), mAct.getResources().getBoolean(R.bool.sort_default)); - if ( sortLists ) { - groupsForViewing = new ArrayList(mGroup.childGroups); - - Collections.sort(entriesForViewing, entryComp); - Collections.sort(groupsForViewing, groupComp); - } else { - groupsForViewing = mGroup.childGroups; - } - } - - public int getCount() { - - return groupsForViewing.size() + entriesForViewing.size(); - } - - public Object getItem(int position) { - return position; - } - - public long getItemId(int position) { - return position; - } - - public View getView(int position, View convertView, ViewGroup parent) { - int size = groupsForViewing.size(); - - if ( position < size ) { - return createGroupView(position, convertView); - } else { - return createEntryView(position - size, convertView); - } - } - - private View createGroupView(int position, View convertView) { - PwGroup group = groupsForViewing.get(position); - PwGroupView gv; - - if (convertView == null || !(convertView instanceof PwGroupView)) { - - gv = PwGroupView.getInstance(mAct, group); - } - else { - gv = (PwGroupView) convertView; - gv.convertView(group); - - } - - return gv; - } - - private PwEntryView createEntryView(int position, View convertView) { - PwEntry entry = entriesForViewing.get(position); - PwEntryView ev; - - if (convertView == null || !(convertView instanceof PwEntryView)) { - ev = PwEntryView.getInstance(mAct, entry, position); - } - else { - ev = (PwEntryView) convertView; - ev.convertView(entry, position); - } - - return ev; - } - -} diff --git a/app/src/main/java/com/keepassdroid/AboutActivity.java b/app/src/main/java/com/keepassdroid/activities/AboutActivity.java similarity index 98% rename from app/src/main/java/com/keepassdroid/AboutActivity.java rename to app/src/main/java/com/keepassdroid/activities/AboutActivity.java index a0356867d..86e44ad7a 100644 --- a/app/src/main/java/com/keepassdroid/AboutActivity.java +++ b/app/src/main/java/com/keepassdroid/activities/AboutActivity.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.activities; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; diff --git a/app/src/main/java/com/keepassdroid/EntryActivity.java b/app/src/main/java/com/keepassdroid/activities/EntryActivity.java similarity index 68% rename from app/src/main/java/com/keepassdroid/EntryActivity.java rename to app/src/main/java/com/keepassdroid/activities/EntryActivity.java index 7b2c3e4ec..0475314d0 100644 --- a/app/src/main/java/com/keepassdroid/EntryActivity.java +++ b/app/src/main/java/com/keepassdroid/activities/EntryActivity.java @@ -18,7 +18,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.activities; import android.app.Activity; import android.app.AlertDialog; @@ -32,14 +32,14 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; -import android.support.v7.widget.Toolbar; import android.support.v4.app.NotificationCompat; +import android.support.v7.widget.Toolbar; import android.text.SpannableString; import android.text.method.LinkMovementMethod; -import android.text.method.PasswordTransformationMethod; import android.text.util.Linkify; import android.view.Menu; import android.view.MenuInflater; @@ -49,22 +49,25 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; -import com.kunzisoft.keepass.KeePass; -import com.kunzisoft.keepass.R; import com.keepassdroid.app.App; import com.keepassdroid.compat.ActivityCompat; +import com.keepassdroid.database.Database; import com.keepassdroid.database.PwDatabase; import com.keepassdroid.database.PwEntry; -import com.keepassdroid.database.PwEntryV4; import com.keepassdroid.database.exception.SamsungClipboardException; import com.keepassdroid.intents.Intents; +import com.keepassdroid.settings.PreferencesUtil; +import com.keepassdroid.tasks.UIToastTask; import com.keepassdroid.utils.EmptyUtils; import com.keepassdroid.utils.MenuUtil; import com.keepassdroid.utils.Types; import com.keepassdroid.utils.Util; +import com.keepassdroid.view.EntryContentsView; +import com.kunzisoft.keepass.KeePass; +import com.kunzisoft.keepass.R; -import java.text.DateFormat; import java.util.Date; +import java.util.Map; import java.util.Timer; import java.util.TimerTask; import java.util.UUID; @@ -73,63 +76,32 @@ import static com.keepassdroid.settings.PreferencesUtil.isClipboardNotifications public class EntryActivity extends LockCloseHideActivity { public static final String KEY_ENTRY = "entry"; - public static final String KEY_REFRESH_POS = "refresh_pos"; public static final int NOTIFY_USERNAME = 1; public static final int NOTIFY_PASSWORD = 2; - - public static void Launch(Activity act, PwEntry pw, int pos) { - Intent i; - - if ( pw instanceof PwEntryV4 ) { - i = new Intent(act, EntryActivityV4.class); - } else { - i = new Intent(act, EntryActivity.class); - } - - i.putExtra(KEY_ENTRY, Types.UUIDtoBytes(pw.getUUID())); - i.putExtra(KEY_REFRESH_POS, pos); - - act.startActivityForResult(i,0); - } + + private ImageView titleIconView; + private TextView titleView; + private EntryContentsView entryContentsView; protected PwEntry mEntry; private Timer mTimer = new Timer(); private boolean mShowPassword; - private int mPos; private NotificationManager mNM; private BroadcastReceiver mIntentReceiver; protected boolean readOnly = false; - - private DateFormat dateFormat; - private DateFormat timeFormat; - - protected void setEntryView() { - setContentView(R.layout.entry_view); - } - - protected void setupEditButtons() { - View edit = findViewById(R.id.entry_edit); - edit.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - EntryEditActivity.Launch(EntryActivity.this, mEntry); - } - - }); - - if (readOnly) { - edit.setVisibility(View.GONE); - } - } + public static void Launch(Activity act, PwEntry pw) { + Intent intent = new Intent(act, EntryActivity.class); + intent.putExtra(KEY_ENTRY, Types.UUIDtoBytes(pw.getUUID())); + act.startActivityForResult(intent, EntryEditActivity.ADD_OR_UPDATE_ENTRY_REQUEST_CODE); + } @Override protected void onCreate(Bundle savedInstanceState) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - mShowPassword = ! prefs.getBoolean(getString(R.string.maskpass_key), getResources().getBoolean(R.bool.maskpass_default)); - super.onCreate(savedInstanceState); - setEntryView(); + + setContentView(R.layout.entry_view); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); @@ -137,10 +109,6 @@ public class EntryActivity extends LockCloseHideActivity { getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close_white_24dp); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); - - Context appCtx = getApplicationContext(); - dateFormat = android.text.format.DateFormat.getDateFormat(appCtx); - timeFormat = android.text.format.DateFormat.getTimeFormat(appCtx); Database db = App.getDB(); // Likely the app has been killed exit the activity @@ -150,12 +118,13 @@ public class EntryActivity extends LockCloseHideActivity { } readOnly = db.readOnly; + mShowPassword = !PreferencesUtil.isPasswordMask(this); + setResult(KeePass.EXIT_NORMAL); + // Get Entry from UUID Intent i = getIntent(); UUID uuid = Types.bytestoUUID(i.getByteArrayExtra(KEY_ENTRY)); - mPos = i.getIntExtra(KEY_REFRESH_POS, -1); - mEntry = db.pm.entries.get(uuid); if (mEntry == null) { Toast.makeText(this, R.string.entry_not_found, Toast.LENGTH_LONG).show(); @@ -168,10 +137,27 @@ public class EntryActivity extends LockCloseHideActivity { // Update last access time. mEntry.touch(false, false); - - fillData(false); - setupEditButtons(); + // Get views + titleIconView = (ImageView) findViewById(R.id.entry_icon); + titleView = (TextView) findViewById(R.id.entry_title); + entryContentsView = (EntryContentsView) findViewById(R.id.entry_contents); + entryContentsView.applyFontVisibilityToFields(PreferencesUtil.fieldFontIsInVisibility(this)); + + fillData(); + + // Setup Edit Buttons + View edit = findViewById(R.id.entry_edit); + edit.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + EntryEditActivity.Launch(EntryActivity.this, mEntry); + } + + }); + if (readOnly) { + edit.setVisibility(View.GONE); + } // If notifications enabled in settings if (isClipboardNotificationsEnable(getApplicationContext())) { @@ -253,60 +239,88 @@ public class EntryActivity extends LockCloseHideActivity { return notify; } - - private String getDateTime(Date dt) { - return dateFormat.format(dt) + " " + timeFormat.format(dt); - - } - - protected void fillData(boolean trimList) { - ImageView iv = (ImageView) findViewById(R.id.entry_icon); + + private void populateTitle(Drawable drawIcon, String text) { + titleIconView.setImageDrawable(drawIcon); + titleView.setText(text); + } + + protected void fillData() { Database db = App.getDB(); - db.drawFactory.assignDrawableTo(iv, getResources(), mEntry.getIcon()); - PwDatabase pm = db.pm; - populateText(R.id.entry_title, mEntry.getTitle(true, pm)); - populateText(R.id.entry_user_name, mEntry.getUsername(true, pm)); - - populateText(R.id.entry_url, mEntry.getUrl(true, pm)); - populateText(R.id.entry_password, mEntry.getPassword(true, pm)); - setPasswordStyle(); - - populateText(R.id.entry_created, getDateTime(mEntry.getCreationTime())); - populateText(R.id.entry_modified, getDateTime(mEntry.getLastModificationTime())); - populateText(R.id.entry_accessed, getDateTime(mEntry.getLastAccessTime())); - + // Assign title + populateTitle(db.drawFactory.getIconDrawable(getResources(), mEntry.getIcon()), + mEntry.getTitle(true, pm)); + + // Assign basic fields + entryContentsView.assignUserName(mEntry.getUsername(true, pm)); + entryContentsView.assignUserNameCopyListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + timeoutCopyToClipboard(mEntry.getUsername(true, App.getDB().pm), + getString(R.string.copy_field, getString(R.string.entry_user_name))); + } + }); + + entryContentsView.assignPassword(mEntry.getPassword(true, pm)); + entryContentsView.assignPasswordCopyListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + timeoutCopyToClipboard(mEntry.getPassword(true, App.getDB().pm), + getString(R.string.copy_field, getString(R.string.entry_password))); + } + }); + + entryContentsView.assignURL(mEntry.getUrl(true, pm)); + + entryContentsView.setHiddenPasswordStyle(!mShowPassword); + entryContentsView.assignComment(mEntry.getNotes(true, pm)); + + // Assign custom fields + if (mEntry.allowExtraFields()) { + entryContentsView.clearExtraFields(); + for (Map.Entry field : mEntry.getExtraFields(pm).entrySet()) { + final String label = field.getKey(); + final String value = field.getValue(); + entryContentsView.addExtraField(label, value, new View.OnClickListener() { + @Override + public void onClick(View view) { + timeoutCopyToClipboard(value, getString(R.string.copy_field, label)); + } + }); + } + } + + // Assign dates + entryContentsView.assignCreationDate(mEntry.getCreationTime()); + entryContentsView.assignModificationDate(mEntry.getLastModificationTime()); + entryContentsView.assignLastAccessDate(mEntry.getLastAccessTime()); Date expires = mEntry.getExpiryTime(); if ( mEntry.expires() ) { - populateText(R.id.entry_expires, getDateTime(expires)); + entryContentsView.assignExpiresDate(expires); } else { - populateText(R.id.entry_expires, R.string.never); + entryContentsView.assignExpiresDate(getString(R.string.never)); } - populateText(R.id.entry_comment, mEntry.getNotes(true, pm)); - - } - - private void populateText(int viewId, int resId) { - TextView tv = (TextView) findViewById(viewId); - tv.setText(resId); - } - - private void populateText(int viewId, String text) { - TextView tv = (TextView) findViewById(viewId); - tv.setText(text); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - if ( resultCode == KeePass.EXIT_REFRESH || resultCode == KeePass.EXIT_REFRESH_TITLE ) { - fillData(true); - if ( resultCode == KeePass.EXIT_REFRESH_TITLE ) { - Intent ret = new Intent(); - ret.putExtra(KEY_REFRESH_POS, mPos); - setResult(KeePass.EXIT_REFRESH, ret); - } + switch (requestCode) { + case EntryEditActivity.ADD_OR_UPDATE_ENTRY_REQUEST_CODE: + fillData(); + break; + } + } + + private void changeShowPasswordIcon(MenuItem togglePassword) { + if ( mShowPassword ) { + togglePassword.setTitle(R.string.menu_hide_password); + togglePassword.setIcon(R.drawable.ic_visibility_off_white_24dp); + } else { + togglePassword.setTitle(R.string.menu_showpass); + togglePassword.setIcon(R.drawable.ic_visibility_white_24dp); } } @@ -317,27 +331,21 @@ public class EntryActivity extends LockCloseHideActivity { MenuInflater inflater = getMenuInflater(); MenuUtil.donationMenuInflater(inflater, menu); inflater.inflate(R.menu.entry, menu); - inflater.inflate(R.menu.lock_database, menu); + inflater.inflate(R.menu.database_lock, menu); MenuItem togglePassword = menu.findItem(R.id.menu_toggle_pass); - if ( mShowPassword ) { - togglePassword.setTitle(R.string.menu_hide_password); - togglePassword.setIcon(R.drawable.ic_visibility_off_white_24dp); - } else { - togglePassword.setTitle(R.string.menu_showpass); - togglePassword.setIcon(R.drawable.ic_visibility_white_24dp); - } + if (!entryContentsView.isPasswordPresent()) { + togglePassword.setVisible(false); + } else { + changeShowPasswordIcon(togglePassword); + } MenuItem gotoUrl = menu.findItem(R.id.menu_goto_url); - MenuItem copyUser = menu.findItem(R.id.menu_copy_user); - MenuItem copyPass = menu.findItem(R.id.menu_copy_pass); // In API >= 11 onCreateOptionsMenu may be called before onCreate completes // so mEntry may not be set if (mEntry == null) { gotoUrl.setVisible(false); - copyUser.setVisible(false); - copyPass.setVisible(false); } else { String url = mEntry.getUrl(); @@ -345,28 +353,10 @@ public class EntryActivity extends LockCloseHideActivity { // disable button if url is not available gotoUrl.setVisible(false); } - if ( mEntry.getUsername().length() == 0 ) { - // disable button if username is not available - copyUser.setVisible(false); - } - if ( mEntry.getPassword().length() == 0 ) { - // disable button if password is not available - copyPass.setVisible(false); - } } return true; } - - private void setPasswordStyle() { - TextView password = (TextView) findViewById(R.id.entry_password); - - if ( mShowPassword ) { - password.setTransformationMethod(null); - } else { - password.setTransformationMethod(PasswordTransformationMethod.getInstance()); - } - } @Override public boolean onOptionsItemSelected(MenuItem item) { @@ -375,16 +365,9 @@ public class EntryActivity extends LockCloseHideActivity { return MenuUtil.onDonationItemSelected(this); case R.id.menu_toggle_pass: - if ( mShowPassword ) { - item.setTitle(R.string.menu_showpass); - item.setIcon(R.drawable.ic_visibility_white_24dp); - mShowPassword = false; - } else { - item.setTitle(R.string.menu_hide_password); - item.setIcon(R.drawable.ic_visibility_off_white_24dp); - mShowPassword = true; - } - setPasswordStyle(); + mShowPassword = !mShowPassword; + changeShowPasswordIcon(item); + entryContentsView.setHiddenPasswordStyle(!mShowPassword); return true; case R.id.menu_goto_url: @@ -403,14 +386,6 @@ public class EntryActivity extends LockCloseHideActivity { } return true; - case R.id.menu_copy_user: - timeoutCopyToClipboard(mEntry.getUsername(true, App.getDB().pm)); - return true; - - case R.id.menu_copy_pass: - timeoutCopyToClipboard(mEntry.getPassword(true, App.getDB().pm)); - return true; - case R.id.menu_lock: App.setShutdown(); setResult(KeePass.EXIT_LOCK); @@ -423,8 +398,15 @@ public class EntryActivity extends LockCloseHideActivity { return super.onOptionsItemSelected(item); } - + private void timeoutCopyToClipboard(String text) { + timeoutCopyToClipboard(text, ""); + } + + private void timeoutCopyToClipboard(String text, String toastString) { + if (!toastString.isEmpty()) + Toast.makeText(EntryActivity.this, toastString, Toast.LENGTH_LONG).show(); + try { Util.copyToClipboard(this, text); } catch (SamsungClipboardException e) { @@ -441,9 +423,17 @@ public class EntryActivity extends LockCloseHideActivity { mTimer.schedule(new ClearClipboardTask(this, text), clipClearTime); } } - - // Setup to allow the toast to happen in the foreground + @Override + public void finish() { + // Transit data in previous Activity after an update + Intent intent = new Intent(); + intent.putExtra(EntryEditActivity.ADD_OR_UPDATE_ENTRY_KEY, mEntry); + setResult(EntryEditActivity.UPDATE_ENTRY_RESULT_CODE, intent); + super.finish(); + } + + // Setup to allow the toast to happen in the foreground final Handler uiThreadCallback = new Handler(); // Task which clears the clipboard, and sends a toast to the foreground. diff --git a/app/src/main/java/com/keepassdroid/activities/EntryEditActivity.java b/app/src/main/java/com/keepassdroid/activities/EntryEditActivity.java new file mode 100644 index 000000000..7c16165bf --- /dev/null +++ b/app/src/main/java/com/keepassdroid/activities/EntryEditActivity.java @@ -0,0 +1,415 @@ +/* + * Copyright 2017 Brian Pellin, 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.activities; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.widget.ImageButton; +import android.widget.LinearLayout; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.Toast; + +import com.keepassdroid.app.App; +import com.keepassdroid.database.Database; +import com.keepassdroid.database.PwDatabase; +import com.keepassdroid.database.PwDatabaseV4; +import com.keepassdroid.database.PwEntry; +import com.keepassdroid.database.PwEntryV4; +import com.keepassdroid.database.PwGroup; +import com.keepassdroid.database.PwGroupId; +import com.keepassdroid.database.PwIconStandard; +import com.keepassdroid.database.edit.AddEntry; +import com.keepassdroid.database.edit.OnFinish; +import com.keepassdroid.database.edit.RunnableOnFinish; +import com.keepassdroid.database.edit.UpdateEntry; +import com.keepassdroid.database.security.ProtectedString; +import com.keepassdroid.fragments.GeneratePasswordDialogFragment; +import com.keepassdroid.fragments.IconPickerDialogFragment; +import com.keepassdroid.icons.Icons; +import com.keepassdroid.settings.PreferencesUtil; +import com.keepassdroid.tasks.ProgressTask; +import com.keepassdroid.utils.MenuUtil; +import com.keepassdroid.utils.Types; +import com.keepassdroid.utils.Util; +import com.keepassdroid.view.EntryEditNewField; +import com.kunzisoft.keepass.KeePass; +import com.kunzisoft.keepass.R; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Map; +import java.util.UUID; + +public class EntryEditActivity extends LockCloseHideActivity + implements IconPickerDialogFragment.IconPickerListener, + GeneratePasswordDialogFragment.GeneratePasswordListener { + + // Keys for current Activity + public static final String KEY_ENTRY = "entry"; + public static final String KEY_PARENT = "parent"; + + // Keys for callback + public static final int ADD_ENTRY_RESULT_CODE = 31; + public static final int UPDATE_ENTRY_RESULT_CODE = 32; + public static final int ADD_OR_UPDATE_ENTRY_REQUEST_CODE = 7129; + public static final String ADD_OR_UPDATE_ENTRY_KEY = "ADD_OR_UPDATE_ENTRY_KEY"; + + protected PwEntry mEntry; + protected PwEntry mCallbackNewEntry; + protected boolean mIsNew; + protected int mSelectedIconID = -1; + + // Views + private ScrollView scrollView; + private TextView entryTitleView; + private TextView entryUserNameView; + private TextView entryUrlView; + private TextView entryPasswordView; + private TextView entryConfirmationPasswordView; + private TextView entryCommentView; + private ViewGroup entryExtraFieldsContainer; + + /** + * launch EntryEditActivity to update an existing entry + * @param act from activity + * @param pw Entry to update + */ + public static void Launch(Activity act, PwEntry pw) { + Intent intent = new Intent(act, EntryEditActivity.class); + intent.putExtra(KEY_ENTRY, Types.UUIDtoBytes(pw.getUUID())); + act.startActivityForResult(intent, ADD_OR_UPDATE_ENTRY_REQUEST_CODE); + } + + /** + * launch EntryEditActivity to add a new entry + * @param act from activity + * @param pwGroup Group who will contains new entry + */ + public static void Launch(Activity act, PwGroup pwGroup) { + Intent intent = new Intent(act, EntryEditActivity.class); + intent.putExtra(KEY_PARENT, pwGroup.getId()); + act.startActivityForResult(intent, ADD_OR_UPDATE_ENTRY_REQUEST_CODE); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.entry_edit); + setResult(KeePass.EXIT_NORMAL); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar.setTitle(getString(R.string.app_name)); + setSupportActionBar(toolbar); + assert getSupportActionBar() != null; + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayShowHomeEnabled(true); + + scrollView = (ScrollView) findViewById(R.id.entry_scroll); + scrollView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); + + entryTitleView = (TextView) findViewById(R.id.entry_title); + entryUserNameView = (TextView) findViewById(R.id.entry_user_name); + entryUrlView = (TextView) findViewById(R.id.entry_url); + entryPasswordView = (TextView) findViewById(R.id.entry_password); + entryConfirmationPasswordView = (TextView) findViewById(R.id.entry_confpassword); + entryCommentView = (TextView) findViewById(R.id.entry_comment); + entryExtraFieldsContainer = (ViewGroup) findViewById(R.id.advanced_container); + + // Likely the app has been killed exit the activity + Database db = App.getDB(); + if ( ! db.Loaded() ) { + finish(); + return; + } + + Intent intent = getIntent(); + byte[] uuidBytes = intent.getByteArrayExtra(KEY_ENTRY); + + PwDatabase pm = db.pm; + if ( uuidBytes == null ) { + PwGroupId parentId = (PwGroupId) intent.getSerializableExtra(KEY_PARENT); + PwGroup parent = pm.groups.get(parentId); + mEntry = PwEntry.getInstance(parent); + mIsNew = true; + } else { + UUID uuid = Types.bytestoUUID(uuidBytes); + mEntry = pm.entries.get(uuid); + mIsNew = false; + fillData(); + } + + View iconButton = findViewById(R.id.icon_button); + iconButton.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + IconPickerDialogFragment.launch(EntryEditActivity.this); + } + }); + + // Generate password button + View generatePassword = findViewById(R.id.generate_button); + generatePassword.setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + GeneratePasswordDialogFragment generatePasswordDialogFragment = new GeneratePasswordDialogFragment(); + generatePasswordDialogFragment.show(getSupportFragmentManager(), "PasswordGeneratorFragment"); + } + }); + + // Save button + View save = findViewById(R.id.entry_save); + save.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + if (!validateBeforeSaving()) { + return; + } + mCallbackNewEntry = populateNewEntry(); + + OnFinish onFinish = new AfterSave(); + EntryEditActivity act = EntryEditActivity.this; + RunnableOnFinish task; + if ( mIsNew ) { + task = new AddEntry(act, App.getDB(), mCallbackNewEntry, onFinish); + } else { + task = new UpdateEntry(act, App.getDB(), mEntry, mCallbackNewEntry, onFinish); + } + ProgressTask pt = new ProgressTask(act, task, R.string.saving_database); + pt.run(); + } + + }); + + + if (mEntry.allowExtraFields()) { + View add = findViewById(R.id.add_new_field); + add.setVisibility(View.VISIBLE); + add.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + EntryEditNewField ees = new EntryEditNewField(EntryEditActivity.this); + ees.setData("", new ProtectedString(false, "")); + entryExtraFieldsContainer.addView(ees); + + // Scroll bottom + scrollView.post(new Runnable() { + @Override + public void run() { + scrollView.fullScroll(ScrollView.FOCUS_DOWN); + } + }); + } + }); + } + } + + protected boolean validateBeforeSaving() { + // Require title + String title = entryTitleView.getText().toString(); + if ( title.length() == 0 ) { + Toast.makeText(this, R.string.error_title_required, Toast.LENGTH_LONG).show(); + return false; + } + + // Validate password + String pass = entryPasswordView.getText().toString(); + String conf = entryConfirmationPasswordView.getText().toString(); + if ( ! pass.equals(conf) ) { + Toast.makeText(this, R.string.error_pass_match, Toast.LENGTH_LONG).show(); + return false; + } + + // Validate extra fields + if (mEntry.allowExtraFields()) { + for (int i = 0; i < entryExtraFieldsContainer.getChildCount(); i++) { + EntryEditNewField entryEditNewField = (EntryEditNewField) entryExtraFieldsContainer.getChildAt(i); + String key = entryEditNewField.getLabel(); + if (key == null || key.length() == 0) { + Toast.makeText(this, R.string.error_string_key, Toast.LENGTH_LONG).show(); + return false; + } + } + } + + return true; + } + + protected PwEntry populateNewEntry() { + if (mEntry instanceof PwEntryV4) { + // TODO backup + PwEntryV4 newEntry = (PwEntryV4) mEntry.clone(true); + newEntry.history = (ArrayList) newEntry.history.clone(); + newEntry.createBackup((PwDatabaseV4) App.getDB().pm); + } + + PwEntry newEntry = mEntry.clone(true); + + Date now = Calendar.getInstance().getTime(); + newEntry.setLastAccessTime(now); + newEntry.setLastModificationTime(now); + + PwDatabase db = App.getDB().pm; + newEntry.setTitle(entryTitleView.getText().toString(), db); + if(mSelectedIconID != -1) + // or TODO icon factory newEntry.setIcon(App.getDB().pm.iconFactory.getIcon(mSelectedIconID)); + newEntry.setIcon(new PwIconStandard(mSelectedIconID)); + else { + if (mIsNew) { + newEntry.setIcon(App.getDB().pm.iconFactory.getIcon(0)); + } + else { + // Keep previous icon, if no new one was selected + newEntry.setIcon(mEntry.icon); + } + } + newEntry.setUrl(entryUrlView.getText().toString(), db); + newEntry.setUsername(entryUserNameView.getText().toString(), db); + newEntry.setNotes(entryCommentView.getText().toString(), db); + newEntry.setPassword(entryPasswordView.getText().toString(), db); + + if (newEntry.allowExtraFields()) { + // Delete all new standard strings + newEntry.removeExtraFields(); + // Add extra fields from views + for (int i = 0; i < entryExtraFieldsContainer.getChildCount(); i++) { + EntryEditNewField view = (EntryEditNewField) entryExtraFieldsContainer.getChildAt(i); + String key = view.getLabel(); + String value = view.getValue(); + boolean protect = view.isProtected(); + newEntry.addField(key, new ProtectedString(protect, value)); + } + } + + return newEntry; + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + + MenuInflater inflater = getMenuInflater(); + MenuUtil.donationMenuInflater(inflater, menu); + + return true; + } + + public boolean onOptionsItemSelected(MenuItem item) { + switch ( item.getItemId() ) { + case R.id.menu_donate: + return MenuUtil.onDonationItemSelected(this); + + case android.R.id.home: + finish(); + } + + return super.onOptionsItemSelected(item); + } + + protected void fillData() { + ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button); + App.getDB().drawFactory.assignDrawableTo(currIconButton, getResources(), mEntry.getIcon()); + + boolean visibilityFont = PreferencesUtil.fieldFontIsInVisibility(this); + + entryTitleView.setText(mEntry.getTitle()); + entryUserNameView.setText(mEntry.getUsername()); + entryUrlView.setText(mEntry.getUrl()); + String password = mEntry.getPassword(); + entryPasswordView.setText(password); + entryConfirmationPasswordView.setText(password); + entryCommentView.setText(mEntry.getNotes()); + Util.applyFontVisibilityToTextView(visibilityFont, entryCommentView); + + if (mEntry.allowExtraFields()) { + LinearLayout container = (LinearLayout) findViewById(R.id.advanced_container); + for (Map.Entry pair : mEntry.getExtraProtectedFields().entrySet()) { + EntryEditNewField entryEditNewField = new EntryEditNewField(EntryEditActivity.this); + entryEditNewField.setData(pair.getKey(), pair.getValue()); + entryEditNewField.setFontVisibility(visibilityFont); + container.addView(entryEditNewField); + } + } + } + + @Override + public void iconPicked(Bundle bundle) { + mSelectedIconID = bundle.getInt(IconPickerDialogFragment.KEY_ICON_ID); + ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button); + currIconButton.setImageResource(Icons.iconToResId(mSelectedIconID)); + } + + @Override + public void acceptPassword(Bundle bundle) { + String generatedPassword = bundle.getString(GeneratePasswordDialogFragment.KEY_PASSWORD_ID); + entryPasswordView.setText(generatedPassword); + entryConfirmationPasswordView.setText(generatedPassword); + } + + @Override + public void cancelPassword(Bundle bundle) { + // Do nothing here + } + + @Override + public void finish() { + // Assign entry callback as a result in all case + if (mCallbackNewEntry != null) { + Intent intentEntry = new Intent(); + if (mIsNew) { + intentEntry.putExtra(ADD_OR_UPDATE_ENTRY_KEY, mCallbackNewEntry); + setResult(ADD_ENTRY_RESULT_CODE, intentEntry); + } else { + intentEntry.putExtra(ADD_OR_UPDATE_ENTRY_KEY, mCallbackNewEntry); + setResult(UPDATE_ENTRY_RESULT_CODE, intentEntry); + } + } + super.finish(); + } + + private final class AfterSave extends OnFinish { + + AfterSave() { + super(new Handler()); + } + + @Override + public void run() { + if ( mSuccess ) { + finish(); + } else { + displayMessage(EntryEditActivity.this); + } + } + } + +} diff --git a/app/src/main/java/com/keepassdroid/activities/GroupActivity.java b/app/src/main/java/com/keepassdroid/activities/GroupActivity.java new file mode 100644 index 000000000..0f579cfde --- /dev/null +++ b/app/src/main/java/com/keepassdroid/activities/GroupActivity.java @@ -0,0 +1,362 @@ +/* + * Copyright 2017 Brian Pellin, 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.activities; + +import android.app.Activity; +import android.app.Dialog; +import android.app.SearchManager; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.os.Handler; +import android.preference.PreferenceManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.SearchView; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.ImageView; + +import com.keepassdroid.adapters.NodeAdapter; +import com.keepassdroid.app.App; +import com.keepassdroid.database.Database; +import com.keepassdroid.database.PwEntry; +import com.keepassdroid.database.PwGroup; +import com.keepassdroid.database.PwGroupId; +import com.keepassdroid.database.PwNode; +import com.keepassdroid.database.SortNodeEnum; +import com.keepassdroid.database.edit.AddGroup; +import com.keepassdroid.database.edit.DeleteEntry; +import com.keepassdroid.database.edit.DeleteGroup; +import com.keepassdroid.dialog.ReadOnlyDialog; +import com.keepassdroid.fragments.AssignMasterKeyDialogFragment; +import com.keepassdroid.fragments.GroupEditDialogFragment; +import com.keepassdroid.fragments.IconPickerDialogFragment; +import com.keepassdroid.search.SearchResultsActivity; +import com.keepassdroid.tasks.ProgressTask; +import com.keepassdroid.view.ListNodesWithAddButtonView; +import com.kunzisoft.keepass.KeePass; +import com.kunzisoft.keepass.R; + +public class GroupActivity extends ListNodesActivity + implements GroupEditDialogFragment.EditGroupListener, IconPickerDialogFragment.IconPickerListener { + + protected boolean addGroupEnabled = false; + protected boolean addEntryEnabled = false; + protected boolean isRoot = false; + protected boolean readOnly = false; + protected EditGroupDialogAction editGroupDialogAction = EditGroupDialogAction.NONE; + private ListNodesWithAddButtonView rootView; + + private enum EditGroupDialogAction { + CREATION, UPDATE, NONE + } + + private static final String TAG = "Group Activity:"; + + public static void Launch(Activity act) { + Launch(act, null); + } + + public static void Launch(Activity act, PwGroup group) { + Intent intent = new Intent(act, GroupActivity.class); + if ( group != null ) { + intent.putExtra(KEY_ENTRY, group.getId()); + } + act.startActivityForResult(intent,0); + } + + @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 + rootView = new ListNodesWithAddButtonView(this); + rootView.enableAddGroup(addGroupEnabled); + rootView.enableAddEntry(addEntryEnabled); + setContentView(rootView); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar.setTitle(""); + setSupportActionBar(toolbar); + + if ( mCurrentGroup.getParent() != null ) + toolbar.setNavigationIcon(R.drawable.ic_arrow_up_white_24dp); + + rootView.setAddGroupClickListener(new View.OnClickListener() { + public void onClick(View v) { + editGroupDialogAction = EditGroupDialogAction.CREATION; + GroupEditDialogFragment groupEditDialogFragment = new GroupEditDialogFragment(); + groupEditDialogFragment.show(getSupportFragmentManager(), + GroupEditDialogFragment.TAG_CREATE_GROUP); + } + }); + rootView.setAddEntryClickListener(new View.OnClickListener() { + public void onClick(View v) { + EntryEditActivity.Launch(GroupActivity.this, mCurrentGroup); + } + }); + + setGroupTitle(); + setGroupIcon(); + + Log.w(TAG, "Finished creating tree"); + + if (isRoot) { + showWarnings(); + } + } + + protected PwGroup initCurrentGroup() { + PwGroup currentGroup; + Database db = App.getDB(); + readOnly = db.readOnly; + PwGroup root = db.pm.rootGroup; + + Log.w(TAG, "Creating tree view"); + PwGroupId pwGroupId = (PwGroupId) getIntent().getSerializableExtra(KEY_ENTRY); + if ( pwGroupId == null ) { + currentGroup = root; + } else { + currentGroup = db.pm.groups.get(pwGroupId); + } + + addGroupEnabled = !readOnly; + addEntryEnabled = !readOnly; + + isRoot = (currentGroup == root); + if ( !currentGroup.allowAddEntryIfIsRoot() ) + addEntryEnabled = !isRoot && addEntryEnabled; + + return currentGroup; + } + + @Override + protected RecyclerView defineNodeList() { + return (RecyclerView) findViewById(R.id.nodes_list); + } + + @Override + protected void addOptionsToAdapter(NodeAdapter nodeAdapter) { + super.addOptionsToAdapter(nodeAdapter); + + nodeAdapter.setActivateContextMenu(true); + nodeAdapter.setNodeMenuListener(new NodeAdapter.NodeMenuListener() { + @Override + public boolean onOpenMenuClick(PwNode node) { + mAdapter.registerANodeToUpdate(node); + switch (node.getType()) { + case GROUP: + GroupActivity.Launch(GroupActivity.this, (PwGroup) node); + break; + case ENTRY: + EntryActivity.Launch(GroupActivity.this, (PwEntry) node); + break; + } + return true; + } + + @Override + public boolean onEditMenuClick(PwNode node) { + mAdapter.registerANodeToUpdate(node); + switch (node.getType()) { + case GROUP: + editGroupDialogAction = EditGroupDialogAction.UPDATE; + GroupEditDialogFragment groupEditDialogFragment = + GroupEditDialogFragment.build(node); + groupEditDialogFragment.show(getSupportFragmentManager(), + GroupEditDialogFragment.TAG_CREATE_GROUP); + break; + case ENTRY: + EntryEditActivity.Launch(GroupActivity.this, (PwEntry) node); + break; + } + return true; + } + + @Override + public boolean onDeleteMenuClick(PwNode node) { + switch (node.getType()) { + case GROUP: + deleteGroup((PwGroup) node); + break; + case ENTRY: + deleteEntry((PwEntry) node); + break; + } + return true; + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + // Show button on resume + rootView.showButton(); + } + + @Override + public void onSortSelected(SortNodeEnum sortNodeEnum, boolean ascending, boolean groupsBefore, boolean recycleBinBottom) { + super.onSortSelected(sortNodeEnum, ascending, groupsBefore, recycleBinBottom); + + // Show button if hide after sort + rootView.showButton(); + } + + protected void setGroupIcon() { + if (mCurrentGroup != null) { + ImageView iv = (ImageView) findViewById(R.id.icon); + App.getDB().drawFactory.assignDrawableTo(iv, getResources(), mCurrentGroup.getIcon()); + } + } + + private void deleteEntry(PwEntry entry) { + Handler handler = new Handler(); + DeleteEntry task = new DeleteEntry(this, App.getDB(), entry, + new AfterDeleteNode(handler, entry)); + ProgressTask pt = new ProgressTask(this, task, R.string.saving_database); + pt.run(); + } + + private void deleteGroup(PwGroup group) { + //TODO Verify trash recycle bin + Handler handler = new Handler(); + DeleteGroup task = new DeleteGroup(this, App.getDB(), group, + new AfterDeleteNode(handler, group)); + ProgressTask pt = new ProgressTask(this, task, R.string.saving_database); + pt.run(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.search, menu); + inflater.inflate(R.menu.database_master_key, menu); + inflater.inflate(R.menu.database_lock, menu); + + // Get the SearchView and set the searchable configuration + SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); + assert searchManager != null; + + MenuItem searchItem = menu.findItem(R.id.menu_search); + SearchView searchView = null; + if (searchItem != null) { + searchView = (SearchView) searchItem.getActionView(); + } + if (searchView != null) { + searchView.setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(this, SearchResultsActivity.class))); + searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default + } + + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + + case android.R.id.home: + onBackPressed(); + return true; + + case R.id.menu_search: + onSearchRequested(); + return true; + + case R.id.menu_lock: + App.setShutdown(); + setResult(KeePass.EXIT_LOCK); + finish(); + return true; + + case R.id.menu_change_master_key: + setPassword(); + return true; + } + return super.onOptionsItemSelected(item); + } + + private void setPassword() { + AssignMasterKeyDialogFragment dialog = new AssignMasterKeyDialogFragment(); + dialog.show(getSupportFragmentManager(), "passwordDialog"); + } + + @Override + public void approveEditGroup(Bundle bundle) { + String GroupName = bundle.getString(GroupEditDialogFragment.KEY_NAME); + int GroupIconID = bundle.getInt(GroupEditDialogFragment.KEY_ICON_ID); + switch (editGroupDialogAction) { + case CREATION: + // If edit group creation + Handler handler = new Handler(); + AddGroup task = new AddGroup(this, App.getDB(), GroupName, GroupIconID, mCurrentGroup, + new AfterAddNode(handler), false); + ProgressTask pt = new ProgressTask(this, task, R.string.saving_database); + pt.run(); + break; + case UPDATE: + // If edit group update + // TODO UpdateGroup + break; + } + editGroupDialogAction = EditGroupDialogAction.NONE; + } + + @Override + public void cancelEditGroup(Bundle bundle) { + // Do nothing here + } + + @Override + // For icon in create tree dialog + public void iconPicked(Bundle bundle) { + GroupEditDialogFragment groupEditDialogFragment = + (GroupEditDialogFragment) getSupportFragmentManager() + .findFragmentByTag(GroupEditDialogFragment.TAG_CREATE_GROUP); + if (groupEditDialogFragment != null) { + groupEditDialogFragment.iconPicked(bundle); + } + } + + protected void showWarnings() { + if (App.getDB().readOnly) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + + if (prefs.getBoolean(getString(R.string.show_read_only_warning), true)) { + Dialog dialog = new ReadOnlyDialog(this); + dialog.show(); + } + } + } +} diff --git a/app/src/main/java/com/keepassdroid/activities/ListNodesActivity.java b/app/src/main/java/com/keepassdroid/activities/ListNodesActivity.java new file mode 100644 index 000000000..688cbebeb --- /dev/null +++ b/app/src/main/java/com/keepassdroid/activities/ListNodesActivity.java @@ -0,0 +1,316 @@ +/* + * Copyright 2017 Brian Pellin, 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.activities; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.preference.PreferenceManager; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.util.Log; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.TextView; + +import com.keepassdroid.adapters.NodeAdapter; +import com.keepassdroid.app.App; +import com.keepassdroid.compat.ActivityCompat; +import com.keepassdroid.compat.EditorCompat; +import com.keepassdroid.database.PwDatabase; +import com.keepassdroid.database.PwEntry; +import com.keepassdroid.database.PwGroup; +import com.keepassdroid.database.PwNode; +import com.keepassdroid.database.edit.AfterAddNodeOnFinish; +import com.keepassdroid.database.edit.OnFinish; +import com.keepassdroid.fragments.AssignMasterKeyDialogFragment; +import com.keepassdroid.fragments.SortDialogFragment; +import com.keepassdroid.settings.PreferencesUtil; +import com.keepassdroid.tasks.UIToastTask; +import com.keepassdroid.utils.MenuUtil; +import com.keepassdroid.database.SortNodeEnum; +import com.keepassdroid.view.AssignPasswordHelper; +import com.kunzisoft.keepass.KeePass; +import com.kunzisoft.keepass.R; + +public abstract class ListNodesActivity extends LockCloseListActivity + implements AssignMasterKeyDialogFragment.AssignPasswordDialogListener, + NodeAdapter.OnNodeClickCallback, + SortDialogFragment.SortSelectionListener { + + public static final String KEY_ENTRY = "entry"; + + protected PwGroup mCurrentGroup; + protected NodeAdapter mAdapter; + + private SharedPreferences prefs; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + if ( isFinishing() ) { + return; + } + + // Likely the app has been killed exit the activity + if ( ! App.getDB().Loaded() ) { + finish(); + return; + } + + prefs = PreferenceManager.getDefaultSharedPreferences(this); + + ActivityCompat.invalidateOptionsMenu(this); + + setContentView(R.layout.list_nodes); + setResult(KeePass.EXIT_NORMAL); + + mCurrentGroup = initCurrentGroup(); + + mAdapter = new NodeAdapter(this); + addOptionsToAdapter(mAdapter); + } + + protected abstract PwGroup initCurrentGroup(); + + protected abstract RecyclerView defineNodeList(); + + protected void addOptionsToAdapter(NodeAdapter nodeAdapter) { + mAdapter.setOnNodeClickListener(this); + } + + @Override + protected void onResume() { + super.onResume(); + // Add elements to the list + mAdapter.rebuildList(mCurrentGroup); + assignListToNodeAdapter(defineNodeList()); + } + + protected void setGroupTitle() { + if ( mCurrentGroup != null ) { + String name = mCurrentGroup.getName(); + TextView tv = (TextView) findViewById(R.id.group_name); + if ( name != null && name.length() > 0 ) { + if ( tv != null ) { + tv.setText(name); + } + } else { + if ( tv != null ) { + tv.setText(getText(R.string.root)); + } + } + } + } + + protected void assignListToNodeAdapter(RecyclerView recyclerView) { + recyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); + // TODO mList.setTextFilterEnabled(true); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + recyclerView.setAdapter(mAdapter); + } + + @Override + public void onNodeClick(PwNode node) { + mAdapter.registerANodeToUpdate(node); + switch (node.getType()) { + case GROUP: + GroupActivity.Launch(this, (PwGroup) node); + break; + case ENTRY: + EntryActivity.Launch(this, (PwEntry) node); + break; + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + + MenuInflater inflater = getMenuInflater(); + MenuUtil.donationMenuInflater(inflater, menu); + inflater.inflate(R.menu.tree, menu); + inflater.inflate(R.menu.default_menu, menu); + + return true; + } + + @Override + public void onSortSelected(SortNodeEnum sortNodeEnum, boolean ascending, boolean groupsBefore, boolean recycleBinBottom) { + // Toggle setting + Editor editor = prefs.edit(); + editor.putString(getString(R.string.sort_node_key), sortNodeEnum.name()); + editor.putBoolean(getString(R.string.sort_ascending_key), ascending); + editor.putBoolean(getString(R.string.sort_group_before_key), groupsBefore); + editor.putBoolean(getString(R.string.sort_recycle_bin_bottom_key), recycleBinBottom); + EditorCompat.apply(editor); + + // Tell the adapter to refresh it's list + mAdapter.notifyChangeSort(sortNodeEnum, ascending, groupsBefore); + mAdapter.rebuildList(mCurrentGroup); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch ( item.getItemId() ) { + + case R.id.menu_sort: + SortDialogFragment sortDialogFragment; + + PwDatabase database = App.getDB().pm; + /* + // TODO Recycle bin bottom + if (database.isRecycleBinAvailable() && database.isRecycleBinEnable()) { + sortDialogFragment = + SortDialogFragment.getInstance( + PrefsUtil.getListSort(this), + PrefsUtil.getAscendingSort(this), + PrefsUtil.getGroupsBeforeSort(this), + PrefsUtil.getRecycleBinBottomSort(this)); + } else { + */ + sortDialogFragment = + SortDialogFragment.getInstance( + PreferencesUtil.getListSort(this), + PreferencesUtil.getAscendingSort(this), + PreferencesUtil.getGroupsBeforeSort(this)); + //} + + sortDialogFragment.show(getSupportFragmentManager(), "sortDialog"); + return true; + + default: + MenuUtil.onDefaultMenuOptionsItemSelected(this, item); + return super.onOptionsItemSelected(item); + } + } + + @Override + public void onAssignKeyDialogPositiveClick( + boolean masterPasswordChecked, String masterPassword, + boolean keyFileChecked, Uri keyFile) { + + AssignPasswordHelper assignPasswordHelper = + new AssignPasswordHelper(this, + masterPassword, keyFile); + assignPasswordHelper.assignPasswordInDatabase(null); + } + + @Override + public void onAssignKeyDialogNegativeClick( + boolean masterPasswordChecked, String masterPassword, + boolean keyFileChecked, Uri keyFile) { + + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + switch (requestCode) { + case EntryEditActivity.ADD_OR_UPDATE_ENTRY_REQUEST_CODE: + if (resultCode == EntryEditActivity.ADD_ENTRY_RESULT_CODE || + resultCode == EntryEditActivity.UPDATE_ENTRY_RESULT_CODE) { + PwNode newNode = (PwNode) data.getSerializableExtra(EntryEditActivity.ADD_OR_UPDATE_ENTRY_KEY); + if (newNode != null) { + if (resultCode == EntryEditActivity.ADD_ENTRY_RESULT_CODE) + mAdapter.addNode(newNode); + if (resultCode == EntryEditActivity.UPDATE_ENTRY_RESULT_CODE) { + //mAdapter.updateLastNodeRegister(newNode); + mAdapter.rebuildList(mCurrentGroup); + } + } else { + Log.e(this.getClass().getName(), "New node can be retrieve in Activity Result"); + } + } + break; + } + } + + @Override + public void startActivityForResult(Intent intent, int requestCode, Bundle options) { + /* + * ACTION_SEARCH automatically forces a new task. This occurs when you open a kdb file in + * another app such as Files or GoogleDrive and then Search for an entry. Here we remove the + * FLAG_ACTIVITY_NEW_TASK flag bit allowing search to open it's activity in the current task. + */ + if (Intent.ACTION_SEARCH.equals(intent.getAction())) { + int flags = intent.getFlags(); + flags &= ~Intent.FLAG_ACTIVITY_NEW_TASK; + intent.setFlags(flags); + } + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + super.startActivityForResult(intent, requestCode, options); + } + } + + class AfterAddNode extends AfterAddNodeOnFinish { + AfterAddNode(Handler handler) { + super(handler); + } + + public void run(PwNode pwNode) { + super.run(); + if (mSuccess) { + mAdapter.addNode(pwNode); + } else { + displayMessage(ListNodesActivity.this); + } + } + } + + class AfterDeleteNode extends OnFinish { + private PwNode pwNode; + + AfterDeleteNode(Handler handler, PwNode pwNode) { + super(handler); + this.pwNode = pwNode; + } + + @Override + public void run() { + if ( mSuccess) { + mAdapter.removeNode(pwNode); + PwGroup parent = pwNode.getParent(); + PwDatabase database = App.getDB().pm; + if (database.isRecycleBinAvailable() && database.isRecycleBinEnable()) { + PwGroup recycleBin = database.getRecycleBin(); + // Add trash if it doesn't exists + if (parent.equals(recycleBin) + && mCurrentGroup.getParent() == null + && !mCurrentGroup.equals(recycleBin)) { + mAdapter.addNode(parent); + } + } + } else { + mHandler.post(new UIToastTask(ListNodesActivity.this, "Unrecoverable error: " + mMessage)); + App.setShutdown(); + finish(); + } + } + } +} diff --git a/app/src/main/java/com/keepassdroid/LockCloseActivity.java b/app/src/main/java/com/keepassdroid/activities/LockCloseActivity.java similarity index 97% rename from app/src/main/java/com/keepassdroid/LockCloseActivity.java rename to app/src/main/java/com/keepassdroid/activities/LockCloseActivity.java index 3e4098a82..2b5f7d658 100644 --- a/app/src/main/java/com/keepassdroid/LockCloseActivity.java +++ b/app/src/main/java/com/keepassdroid/activities/LockCloseActivity.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.activities; import android.content.ActivityNotFoundException; import android.content.Intent; diff --git a/app/src/main/java/com/keepassdroid/LockCloseHideActivity.java b/app/src/main/java/com/keepassdroid/activities/LockCloseHideActivity.java similarity index 96% rename from app/src/main/java/com/keepassdroid/LockCloseHideActivity.java rename to app/src/main/java/com/keepassdroid/activities/LockCloseHideActivity.java index ede54ae8b..4490e6a2c 100644 --- a/app/src/main/java/com/keepassdroid/LockCloseHideActivity.java +++ b/app/src/main/java/com/keepassdroid/activities/LockCloseHideActivity.java @@ -17,11 +17,10 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.activities; import com.keepassdroid.compat.BuildCompat; -import android.os.Build; import android.os.Bundle; import android.view.WindowManager.LayoutParams; diff --git a/app/src/main/java/com/keepassdroid/LockCloseListActivity.java b/app/src/main/java/com/keepassdroid/activities/LockCloseListActivity.java similarity index 96% rename from app/src/main/java/com/keepassdroid/LockCloseListActivity.java rename to app/src/main/java/com/keepassdroid/activities/LockCloseListActivity.java index 14af8f22c..4aa3dd2bc 100644 --- a/app/src/main/java/com/keepassdroid/LockCloseListActivity.java +++ b/app/src/main/java/com/keepassdroid/activities/LockCloseListActivity.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.activities; import com.keepassdroid.timeout.TimeoutHelper; diff --git a/app/src/main/java/com/keepassdroid/LockingActivity.java b/app/src/main/java/com/keepassdroid/activities/LockingActivity.java similarity index 89% rename from app/src/main/java/com/keepassdroid/LockingActivity.java rename to app/src/main/java/com/keepassdroid/activities/LockingActivity.java index 51779ffb0..70066ce80 100644 --- a/app/src/main/java/com/keepassdroid/LockingActivity.java +++ b/app/src/main/java/com/keepassdroid/activities/LockingActivity.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.activities; import android.content.BroadcastReceiver; @@ -31,7 +31,6 @@ import com.keepassdroid.app.App; import com.keepassdroid.settings.PreferencesUtil; import com.keepassdroid.stylish.StylishActivity; import com.keepassdroid.timeout.TimeoutHelper; -import com.kunzisoft.keepass.KeePass; public abstract class LockingActivity extends StylishActivity { @@ -52,17 +51,10 @@ public abstract class LockingActivity extends StylishActivity { protected void onResume() { super.onResume(); - checkShutdown(); + TimeoutHelper.checkShutdown(this); TimeoutHelper.resume(this); } - private void checkShutdown() { - if ( App.isShutdown() && App.getDB().Loaded() ) { - setResult(KeePass.EXIT_LOCK); - finish(); - } - } - @Override protected void onPause() { super.onPause(); @@ -86,7 +78,7 @@ public abstract class LockingActivity extends StylishActivity { if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { if (PreferencesUtil.isLockDatabaseWhenScreenShutOffEnable(LockingActivity.this)) { App.setShutdown(); - checkShutdown(); + TimeoutHelper.checkShutdown(LockingActivity.this); } } } diff --git a/app/src/main/java/com/keepassdroid/adapters/BasicViewHolder.java b/app/src/main/java/com/keepassdroid/adapters/BasicViewHolder.java new file mode 100644 index 000000000..b9e4a380f --- /dev/null +++ b/app/src/main/java/com/keepassdroid/adapters/BasicViewHolder.java @@ -0,0 +1,17 @@ +package com.keepassdroid.adapters; + +import android.support.v7.widget.RecyclerView; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +abstract class BasicViewHolder extends RecyclerView.ViewHolder { + + View container; + ImageView icon; + TextView text; + + BasicViewHolder(View itemView) { + super(itemView); + } +} diff --git a/app/src/main/java/com/keepassdroid/adapters/EntryViewHolder.java b/app/src/main/java/com/keepassdroid/adapters/EntryViewHolder.java new file mode 100644 index 000000000..5c14998be --- /dev/null +++ b/app/src/main/java/com/keepassdroid/adapters/EntryViewHolder.java @@ -0,0 +1,17 @@ +package com.keepassdroid.adapters; + +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import com.kunzisoft.keepass.R; + +class EntryViewHolder extends BasicViewHolder { + + EntryViewHolder(View itemView) { + super(itemView); + container = itemView.findViewById(R.id.entry_container); + icon = (ImageView) itemView.findViewById(R.id.entry_icon); + text = (TextView) itemView.findViewById(R.id.entry_text); + } +} diff --git a/app/src/main/java/com/keepassdroid/adapters/GroupViewHolder.java b/app/src/main/java/com/keepassdroid/adapters/GroupViewHolder.java new file mode 100644 index 000000000..0fd6aca61 --- /dev/null +++ b/app/src/main/java/com/keepassdroid/adapters/GroupViewHolder.java @@ -0,0 +1,17 @@ +package com.keepassdroid.adapters; + +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import com.kunzisoft.keepass.R; + +class GroupViewHolder extends BasicViewHolder { + + GroupViewHolder(View itemView) { + super(itemView); + container = itemView.findViewById(R.id.group_container); + icon = (ImageView) itemView.findViewById(R.id.group_icon); + text = (TextView) itemView.findViewById(R.id.group_text); + } +} diff --git a/app/src/main/java/com/keepassdroid/adapters/NodeAdapter.java b/app/src/main/java/com/keepassdroid/adapters/NodeAdapter.java new file mode 100644 index 000000000..2927a1ee6 --- /dev/null +++ b/app/src/main/java/com/keepassdroid/adapters/NodeAdapter.java @@ -0,0 +1,293 @@ +/* + * Copyright 2018 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.adapters; + +import android.content.Context; +import android.support.v7.util.SortedList; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.util.SortedListAdapterCallback; +import android.util.Log; +import android.view.ContextMenu; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; + +import com.keepassdroid.app.App; +import com.keepassdroid.database.PwGroup; +import com.keepassdroid.database.PwNode; +import com.keepassdroid.settings.PreferencesUtil; +import com.keepassdroid.database.SortNodeEnum; +import com.kunzisoft.keepass.R; + +public class NodeAdapter extends RecyclerView.Adapter { + + private SortedList nodeSortedList; + + private Context context; + private LayoutInflater inflater; + private float textSize; + private SortNodeEnum listSort; + private boolean groupsBeforeSort; + private boolean ascendingSort; + + private OnNodeClickCallback onNodeClickCallback; + private int nodePositionToUpdate; + private NodeMenuListener nodeMenuListener; + private boolean activateContextMenu; + + /** + * Create node list adapter with contextMenu or not + * @param context Context to use + */ + public NodeAdapter(final Context context) { + this.inflater = LayoutInflater.from(context); + this.context = context; + this.textSize = PreferencesUtil.getListTextSize(context); + this.listSort = PreferencesUtil.getListSort(context); + this.groupsBeforeSort = PreferencesUtil.getGroupsBeforeSort(context); + this.ascendingSort = PreferencesUtil.getAscendingSort(context); + this.activateContextMenu = false; + this.nodePositionToUpdate = -1; + + this.nodeSortedList = new SortedList<>(PwNode.class, new SortedListAdapterCallback(this) { + @Override public int compare(PwNode item1, PwNode item2) { + return listSort.getNodeComparator(ascendingSort, groupsBeforeSort).compare(item1, item2); + } + + @Override public boolean areContentsTheSame(PwNode oldItem, PwNode newItem) { + return oldItem.isContentVisuallyTheSame(newItem); + } + + @Override public boolean areItemsTheSame(PwNode item1, PwNode item2) { + return item1.equals(item2); + } + }); + } + + public void setActivateContextMenu(boolean activate) { + this.activateContextMenu = activate; + } + + /** + * Rebuild the list by clear and build children from the group + */ + public void rebuildList(PwGroup group) { + this.nodeSortedList.clear(); + this.nodeSortedList.addAll(group.getDirectChildren()); + } + + /** + * Add a node to the list + * @param node Node to add + */ + public void addNode(PwNode node) { + nodeSortedList.add(node); + } + + /** + * Register a node to update before an action + * Call updateLastNodeRegister() after the action to update the node + * @param node Node to register + */ + public void registerANodeToUpdate(PwNode node) { + nodePositionToUpdate = nodeSortedList.indexOf(node); + } + + /** + * Update the last Node register in the list + * Work if only registerANodeToUpdate(PwNode node) is called before + */ + public void updateLastNodeRegister(PwNode node) { + // Don't really update here, sorted list knows each original ref, so we just notify a change + try { + if (nodePositionToUpdate != -1) { + // Don't know why but there is a bug to remove a node after this update + nodeSortedList.updateItemAt(nodePositionToUpdate, node); + nodeSortedList.recalculatePositionOfItemAt(nodePositionToUpdate); + nodePositionToUpdate = -1; + } + else { + Log.e(NodeAdapter.class.getName(), "registerANodeToUpdate must be called before updateLastNodeRegister"); + } + } catch (IndexOutOfBoundsException e) { + Log.e(NodeAdapter.class.getName(), e.getMessage()); + } + } + + /** + * Remove node in the list + * @param node Node to delete + */ + public void removeNode(PwNode node) { + nodeSortedList.remove(node); + } + + /** + * Notify a change sort of the list + */ + public void notifyChangeSort(SortNodeEnum sortNodeEnum, boolean ascending, boolean groupsBefore) { + this.listSort = sortNodeEnum; + this.ascendingSort = ascending; + this.groupsBeforeSort = groupsBefore; + } + + @Override + public int getItemViewType(int position) { + return nodeSortedList.get(position).getType().ordinal(); + } + + @Override + public BasicViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + BasicViewHolder basicViewHolder; + View view; + if (viewType == PwNode.Type.GROUP.ordinal()) { + view = inflater.inflate(R.layout.list_nodes_group, parent, false); + basicViewHolder = new GroupViewHolder(view); + } else { + view = inflater.inflate(R.layout.list_nodes_entry, parent, false); + basicViewHolder = new EntryViewHolder(view); + } + return basicViewHolder; + } + + @Override + public void onBindViewHolder(BasicViewHolder holder, int position) { + PwNode subNode = nodeSortedList.get(position); + // Assign image + App.getDB().drawFactory.assignDrawableTo(holder.icon, + context.getResources(), subNode.getIcon()); + // Assign text + holder.text.setText(subNode.getDisplayTitle()); + // Assign click + holder.container.setOnClickListener( + new OnNodeClickListener(subNode)); + // Context menu + if (activateContextMenu) { + holder.container.setOnCreateContextMenuListener( + new ContextMenuBuilder(subNode, nodeMenuListener)); + } + // Assign text size + holder.text.setTextSize(textSize); + } + + @Override + public int getItemCount() { + return nodeSortedList.size(); + } + + /** + * Assign a listener when a node is clicked + */ + public void setOnNodeClickListener(OnNodeClickCallback onNodeClickCallback) { + this.onNodeClickCallback = onNodeClickCallback; + } + + /** + * Assign a listener when an element of menu is clicked + */ + public void setNodeMenuListener(NodeMenuListener nodeMenuListener) { + this.nodeMenuListener = nodeMenuListener; + } + + /** + * Callback listener to redefine to do an action when a node is click + */ + public interface OnNodeClickCallback { + void onNodeClick(PwNode node); + } + + /** + * Menu listener to redefine to do an action in menu + */ + public interface NodeMenuListener { + boolean onOpenMenuClick(PwNode node); + boolean onEditMenuClick(PwNode node); + boolean onDeleteMenuClick(PwNode node); + } + + /** + * Utility class for node listener + */ + private class OnNodeClickListener implements View.OnClickListener { + private PwNode node; + + OnNodeClickListener(PwNode node) { + this.node = node; + } + + @Override + public void onClick(View v) { + if (onNodeClickCallback != null) + onNodeClickCallback.onNodeClick(node); + } + } + + /** + * Utility class for menu listener + */ + private class ContextMenuBuilder implements View.OnCreateContextMenuListener { + + private static final int MENU_OPEN = Menu.FIRST; + private static final int MENU_EDIT = MENU_OPEN + 1; + private static final int MENU_DELETE = MENU_EDIT + 1; + + private PwNode node; + private NodeMenuListener menuListener; + + ContextMenuBuilder(PwNode node, NodeMenuListener menuListener) { + this.menuListener = menuListener; + this.node = node; + } + + @Override + public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) { + MenuItem clearMenu = contextMenu.add(Menu.NONE, MENU_OPEN, Menu.NONE, R.string.menu_open); + clearMenu.setOnMenuItemClickListener(mOnMyActionClickListener); + if (!App.getDB().readOnly && !node.equals(App.getDB().pm.getRecycleBin())) { + // TODO make edit for group + // clearMenu = contextMenu.add(Menu.NONE, MENU_EDIT, Menu.NONE, R.string.menu_edit); + // clearMenu.setOnMenuItemClickListener(mOnMyActionClickListener); + clearMenu = contextMenu.add(Menu.NONE, MENU_DELETE, Menu.NONE, R.string.menu_delete); + clearMenu.setOnMenuItemClickListener(mOnMyActionClickListener); + } + } + + private MenuItem.OnMenuItemClickListener mOnMyActionClickListener = new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + if (menuListener == null) + return false; + switch ( item.getItemId() ) { + case MENU_OPEN: + return menuListener.onOpenMenuClick(node); + case MENU_EDIT: + return menuListener.onEditMenuClick(node); + case MENU_DELETE: + return menuListener.onDeleteMenuClick(node); + default: + return false; + } + } + }; + } +} diff --git a/app/src/main/java/com/keepassdroid/app/App.java b/app/src/main/java/com/keepassdroid/app/App.java index 1746d0143..08b06db66 100644 --- a/app/src/main/java/com/keepassdroid/app/App.java +++ b/app/src/main/java/com/keepassdroid/app/App.java @@ -21,7 +21,7 @@ package com.keepassdroid.app; import android.app.Application; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.compat.PRNGFixes; import com.keepassdroid.fileselect.RecentFileHistory; import com.keepassdroid.stylish.Stylish; diff --git a/app/src/main/java/com/keepassdroid/Database.java b/app/src/main/java/com/keepassdroid/database/Database.java similarity index 92% rename from app/src/main/java/com/keepassdroid/Database.java rename to app/src/main/java/com/keepassdroid/database/Database.java index 24e5b7467..604d0a778 100644 --- a/app/src/main/java/com/keepassdroid/Database.java +++ b/app/src/main/java/com/keepassdroid/database/Database.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.database; import android.content.Context; import android.content.SharedPreferences; @@ -25,9 +25,6 @@ import android.net.Uri; import android.preference.PreferenceManager; import android.util.Log; -import com.keepassdroid.database.PwDatabase; -import com.keepassdroid.database.PwDatabaseV3; -import com.keepassdroid.database.PwGroup; import com.keepassdroid.database.exception.ContentFileNotFoundException; import com.keepassdroid.database.exception.InvalidDBException; import com.keepassdroid.database.exception.InvalidPasswordException; @@ -37,6 +34,7 @@ import com.keepassdroid.database.load.ImporterFactory; import com.keepassdroid.database.save.PwDbOutput; import com.keepassdroid.icons.DrawableFactory; import com.keepassdroid.search.SearchDbHelper; +import com.keepassdroid.tasks.UpdateStatus; import com.keepassdroid.utils.UriUtil; import com.kunzisoft.keepass.R; @@ -48,14 +46,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.SyncFailedException; -import java.util.HashSet; -import java.util.Set; /** * @author bpellin */ public class Database { - public Set dirty = new HashSet(); public PwDatabase pm; public Uri mUri; public SearchDbHelper searchHelper; @@ -222,7 +217,6 @@ public class Database { } public void clear() { - dirty.clear(); drawFactory.clear(); pm = null; @@ -230,16 +224,4 @@ public class Database { loaded = false; passwordEncodingError = false; } - - public void markAllGroupsAsDirty() { - for ( PwGroup group : pm.getGroups() ) { - dirty.add(group); - } - - // TODO: This should probably be abstracted out - // The root tree in v3 is not an 'official' tree - if ( pm instanceof PwDatabaseV3 ) { - dirty.add(pm.rootGroup); - } - } } diff --git a/app/src/main/java/com/keepassdroid/database/PwDatabase.java b/app/src/main/java/com/keepassdroid/database/PwDatabase.java index bba2971d7..d7d70f269 100644 --- a/app/src/main/java/com/keepassdroid/database/PwDatabase.java +++ b/app/src/main/java/com/keepassdroid/database/PwDatabase.java @@ -19,12 +19,8 @@ */ package com.keepassdroid.database; -import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; @@ -36,8 +32,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import android.os.DropBoxManager.Entry; - import com.keepassdroid.crypto.finalkey.FinalKey; import com.keepassdroid.crypto.finalkey.FinalKeyFactory; import com.keepassdroid.database.exception.InvalidKeyFileException; @@ -252,7 +246,7 @@ public abstract class PwDatabase { public abstract void setNumRounds(long rounds) throws NumberFormatException; - public abstract boolean appSettingsEnabled(); + public abstract boolean algorithmSettingsEnabled(); public abstract PwEncryptionAlgorithm getEncAlgorithm(); @@ -262,7 +256,7 @@ public abstract class PwDatabase { parent = rootGroup; } - parent.childGroups.add(newGroup); + parent.addChildGroup(newGroup); newGroup.setParent(parent); groups.put(newGroup.getId(), newGroup); @@ -271,15 +265,16 @@ public abstract class PwDatabase { public void removeGroupFrom(PwGroup remove, PwGroup parent) { // Remove tree from parent tree - parent.childGroups.remove(remove); - + if (parent != null) { + parent.removeChildGroup(remove); + } groups.remove(remove.getId()); } public void addEntryTo(PwEntry newEntry, PwGroup parent) { // Add entry to parent if (parent != null) { - parent.childEntries.add(newEntry); + parent.addChildEntry(newEntry); } newEntry.setParent(parent); @@ -289,7 +284,7 @@ public abstract class PwDatabase { public void removeEntryFrom(PwEntry remove, PwGroup parent) { // Remove entry for parent if (parent != null) { - parent.childEntries.remove(remove); + parent.removeChildEntry(remove); } entries.remove(remove.getUUID()); } @@ -337,28 +332,73 @@ public abstract class PwDatabase { } } + /** + * Determine if RecycleBin is available or not for this version of database + * @return true if RecycleBin enable + */ + public boolean isRecycleBinAvailable() { + return false; + } + + /** + * Determine if RecycleBin is enable or not + * @return true if RecycleBin enable, false if is not available or not enable + */ + public boolean isRecycleBinEnable() { + return false; + } + + /** + * Define if a Group must be delete or recycle + * @param group Group to remove + * @return true if group can be recycle, false elsewhere + */ public boolean canRecycle(PwGroup group) { return false; } + /** + * Define if an Entry must be delete or recycle + * @param entry Entry to remove + * @return true if entry can be recycle, false elsewhere + */ public boolean canRecycle(PwEntry entry) { return false; } + public void recycle(PwGroup group) { + // Assume calls to this are protected by calling inRecyleBin + throw new RuntimeException("Call not valid for .kdb databases."); + } + public void recycle(PwEntry entry) { // Assume calls to this are protected by calling inRecyleBin throw new RuntimeException("Call not valid for .kdb databases."); } + public void undoRecycle(PwGroup group, PwGroup origParent) { + throw new RuntimeException("Call not valid for .kdb databases."); + } + public void undoRecycle(PwEntry entry, PwGroup origParent) { throw new RuntimeException("Call not valid for .kdb databases."); } + public void deleteGroup(PwGroup group) { + PwGroup parent = group.getParent(); + removeGroupFrom(group, parent); + parent.touch(false, true); + } + public void deleteEntry(PwEntry entry) { PwGroup parent = entry.getParent(); removeEntryFrom(entry, parent); parent.touch(false, true); + } + // TODO Delete group + public void undoDeleteGroup(PwGroup group, PwGroup origParent) { + addGroupTo(group, origParent); } public void undoDeleteEntry(PwEntry entry, PwGroup origParent) { diff --git a/app/src/main/java/com/keepassdroid/database/PwDatabaseV3.java b/app/src/main/java/com/keepassdroid/database/PwDatabaseV3.java index 5e7aeffa3..f296721f3 100644 --- a/app/src/main/java/com/keepassdroid/database/PwDatabaseV3.java +++ b/app/src/main/java/com/keepassdroid/database/PwDatabaseV3.java @@ -51,7 +51,6 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Random; -import java.util.UUID; import com.keepassdroid.database.exception.InvalidKeyFileException; @@ -76,7 +75,7 @@ public class PwDatabaseV3 extends PwDatabase { // Algorithm used to encrypt the database public PwEncryptionAlgorithm algorithm; public int numKeyEncRounds; - + @Override public PwEncryptionAlgorithm getEncAlgorithm() { return algorithm; @@ -164,7 +163,7 @@ public class PwDatabaseV3 extends PwDatabase { List rootChildGroups = getGrpRoots(); root.setGroups(rootChildGroups); - root.childEntries = new ArrayList(); + root.childEntries = new ArrayList<>(); root.level = -1; for (int i = 0; i < rootChildGroups.size(); i++) { PwGroupV3 grp = (PwGroupV3) rootChildGroups.get(i); @@ -180,12 +179,12 @@ public class PwDatabaseV3 extends PwDatabase { currentGroup.childEntries = getEntries(currentGroup); // set parent in child entries - for (int i = 0; i < currentGroup.childEntries.size(); i++) { + for (int i = 0; i < currentGroup.numbersOfChildEntries(); i++) { PwEntryV3 entry = (PwEntryV3) currentGroup.childEntries.get(i); entry.parent = currentGroup; } // recursively construct child groups - for (int i = 0; i < currentGroup.childGroups.size(); i++) { + for (int i = 0; i < currentGroup.numbersOfChildGroups(); i++) { PwGroupV3 grp = (PwGroupV3) currentGroup.childGroups.get(i); grp.parent = currentGroup; constructTree((PwGroupV3) currentGroup.childGroups.get(i)); @@ -263,7 +262,7 @@ public class PwDatabaseV3 extends PwDatabase { } @Override - public boolean appSettingsEnabled() { + public boolean algorithmSettingsEnabled() { return true; } diff --git a/app/src/main/java/com/keepassdroid/database/PwDatabaseV4.java b/app/src/main/java/com/keepassdroid/database/PwDatabaseV4.java index 1f5fc51eb..d9baddded 100644 --- a/app/src/main/java/com/keepassdroid/database/PwDatabaseV4.java +++ b/app/src/main/java/com/keepassdroid/database/PwDatabaseV4.java @@ -300,7 +300,7 @@ public class PwDatabaseV4 extends PwDatabase { } @Override - public boolean appSettingsEnabled() { + public boolean algorithmSettingsEnabled() { return false; } @@ -360,15 +360,23 @@ public class PwDatabaseV4 extends PwDatabase { recycleBinUUID = recycleBin.uuid; } } + + @Override + public boolean isRecycleBinAvailable() { + return true; + } + + @Override + public boolean isRecycleBinEnable() { + return recycleBinEnabled; + } @Override public boolean canRecycle(PwGroup group) { if (!recycleBinEnabled) { return false; } - PwGroup recycle = getRecycleBin(); - return (recycle == null) || (!group.isContainedIn(recycle)); } @@ -377,11 +385,25 @@ public class PwDatabaseV4 extends PwDatabase { if (!recycleBinEnabled) { return false; } - PwGroup parent = entry.getParent(); return (parent != null) && canRecycle(parent); } - + + @Override + public void recycle(PwGroup group) { + ensureRecycleBin(); + + PwGroup parent = group.getParent(); + removeGroupFrom(group, parent); + parent.touch(false, true); + + PwGroup recycleBin = getRecycleBin(); + addGroupTo(group, recycleBin); + + group.touch(false, true); + // TODO ? group.touchLocation(); + } + @Override public void recycle(PwEntry entry) { ensureRecycleBin(); @@ -397,6 +419,15 @@ public class PwDatabaseV4 extends PwDatabase { entry.touchLocation(); } + @Override + public void undoRecycle(PwGroup group, PwGroup origParent) { + + PwGroup recycleBin = getRecycleBin(); + removeGroupFrom(group, recycleBin); + + addGroupTo(group, origParent); + } + @Override public void undoRecycle(PwEntry entry, PwGroup origParent) { @@ -409,15 +440,14 @@ public class PwDatabaseV4 extends PwDatabase { @Override public void deleteEntry(PwEntry entry) { super.deleteEntry(entry); - deletedObjects.add(new PwDeletedObject(entry.getUUID())); } @Override public void undoDeleteEntry(PwEntry entry, PwGroup origParent) { super.undoDeleteEntry(entry, origParent); - - deletedObjects.remove(entry); + // TODO undo delete entry + deletedObjects.remove(entry); } @Override diff --git a/app/src/main/java/com/keepassdroid/database/PwDate.java b/app/src/main/java/com/keepassdroid/database/PwDate.java index 298fba6cf..e144349ec 100644 --- a/app/src/main/java/com/keepassdroid/database/PwDate.java +++ b/app/src/main/java/com/keepassdroid/database/PwDate.java @@ -19,6 +19,7 @@ */ package com.keepassdroid.database; +import java.io.Serializable; import java.util.Arrays; import java.util.Calendar; import java.util.Date; @@ -32,7 +33,7 @@ import com.keepassdroid.utils.Types; * @author bpellin * */ -public class PwDate implements Cloneable { +public class PwDate implements Cloneable, Serializable { private static final int DATE_SIZE = 5; diff --git a/app/src/main/java/com/keepassdroid/database/PwEntry.java b/app/src/main/java/com/keepassdroid/database/PwEntry.java index ee2213301..46819c5ce 100644 --- a/app/src/main/java/com/keepassdroid/database/PwEntry.java +++ b/app/src/main/java/com/keepassdroid/database/PwEntry.java @@ -19,36 +19,22 @@ */ package com.keepassdroid.database; +import com.keepassdroid.database.iterator.EntrySearchStringIterator; +import com.keepassdroid.database.security.ProtectedString; + import java.util.Comparator; import java.util.Date; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; -import com.keepassdroid.database.iterator.EntrySearchStringIterator; -import com.keepassdroid.utils.SprEngine; - -public abstract class PwEntry implements Cloneable { +public abstract class PwEntry extends PwNode implements Cloneable { protected static final String PMS_TAN_ENTRY = ""; - public static class EntryNameComparator implements Comparator { - - public int compare(PwEntry object1, PwEntry object2) { - return object1.getTitle().compareToIgnoreCase(object2.getTitle()); - } - - } - public PwIconStandard icon = PwIconStandard.FIRST; - - public PwEntry() { - - } public static PwEntry getInstance(PwGroup parent) { - return PwEntry.getInstance(parent, true, true); - } - - public static PwEntry getInstance(PwGroup parent, boolean initId, boolean initDates) { if (parent instanceof PwGroupV3) { return new PwEntryV3((PwGroupV3)parent); } @@ -72,12 +58,17 @@ public abstract class PwEntry implements Cloneable { return newEntry; } - + public PwEntry clone(boolean deepStrings) { return (PwEntry) clone(); } - - public void assign(PwEntry source) { + + @Override + public Type getType() { + return Type.ENTRY; + } + + public void assign(PwEntry source) { icon = source.icon; } @@ -109,12 +100,10 @@ public abstract class PwEntry implements Cloneable { public abstract String getPassword(boolean decodeRef, PwDatabase db); public abstract String getUrl(boolean decodeRef, PwDatabase db); public abstract String getNotes(boolean decodeRef, PwDatabase db); - public abstract Date getCreationTime(); public abstract Date getLastModificationTime(); public abstract Date getLastAccessTime(); public abstract Date getExpiryTime(); public abstract boolean expires(); - public abstract PwGroup getParent(); public abstract void setTitle(String title, PwDatabase db); public abstract void setUsername(String user, PwDatabase db); @@ -147,11 +136,53 @@ public abstract class PwEntry implements Cloneable { } } + // TODO encapsulate extra fields + /** + * To redefine if version of entry allow extra field, + * @return true if entry allows extra field + */ + public boolean allowExtraFields() { + return false; + } + + /** + * Retrieve extra fields to show, key is the label, value is the value of field + * @param pm Database + * @return Map of label/value + */ + public Map getExtraFields(PwDatabase pm) { + return new HashMap<>(); + } + + /** + * Retrieve extra protected fields to show, key is the label, value is the value protected of field + * @return Map of label/value + */ + public Map getExtraProtectedFields() { + return new HashMap<>(); + } + + /** + * Add an extra field to the list + * @param label Label of field, must be unique + * @param value Value of field + */ + public void addField(String label, ProtectedString value) {} + + /** + * Delete all extra fields + */ + public void removeExtraFields() {} + + /** + * If it's a node with only meta information like Meta-info SYSTEM Database Color + * @return false by default, true if it's a meta stream + */ public boolean isMetaStream() { return false; } - + public EntrySearchStringIterator stringIterator() { return EntrySearchStringIterator.getInstance(this); } @@ -173,10 +204,87 @@ public abstract class PwEntry implements Cloneable { public void touchLocation() { } - public abstract void setParent(PwGroup parent); - public boolean isSearchingEnabled() { return false; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PwEntry pwEntry = (PwEntry) o; + return isSameType(pwEntry) + && (getUUID() != null ? getUUID().equals(pwEntry.getUUID()) : pwEntry.getUUID() == null); + } + + @Override + public int hashCode() { + return getUUID() != null ? getUUID().hashCode() : 0; + } + + /** + * Comparator of Entry by Name + */ + public static class EntryNameComparator implements Comparator { + + private boolean ascending; + + public EntryNameComparator() { + this(true); + } + + public EntryNameComparator(boolean ascending) { + this.ascending = ascending; + } + + public int compare(PwEntry object1, PwEntry object2) { + if (object1.equals(object2)) + return 0; + + int entryTitleComp = object1.getTitle().compareToIgnoreCase(object2.getTitle()); + // If same title, can be different + if (entryTitleComp == 0) { + return object1.hashCode() - object2.hashCode(); + } + // If descending + if (!ascending) + entryTitleComp = -entryTitleComp; + + return entryTitleComp; + } + } + + /** + * Comparator of Entry by Creation + */ + public static class EntryCreationComparator implements Comparator { + + private boolean ascending; + + public EntryCreationComparator() { + this(true); + } + + public EntryCreationComparator(boolean ascending) { + this.ascending = ascending; + } + + public int compare(PwEntry object1, PwEntry object2) { + if (object1.equals(object2)) + return 0; + + int entryCreationComp = object1.getCreationTime().compareTo(object2.getCreationTime()); + // If same creation, can be different + if (entryCreationComp == 0) { + return object1.hashCode() - object2.hashCode(); + } + // If descending + if (!ascending) + entryCreationComp = -entryCreationComp; + + return entryCreationComp; + } + } + } diff --git a/app/src/main/java/com/keepassdroid/database/PwEntryV3.java b/app/src/main/java/com/keepassdroid/database/PwEntryV3.java index b19609ed1..5a04b64a0 100644 --- a/app/src/main/java/com/keepassdroid/database/PwEntryV3.java +++ b/app/src/main/java/com/keepassdroid/database/PwEntryV3.java @@ -43,14 +43,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA package com.keepassdroid.database; // PhoneID +import com.keepassdroid.utils.Types; + import java.io.UnsupportedEncodingException; import java.util.Calendar; import java.util.Date; import java.util.Random; import java.util.UUID; -import com.keepassdroid.utils.Types; - /** * Structure containing information about one entry. @@ -191,9 +191,8 @@ public class PwEntryV3 extends PwEntry { tLastMod = new PwDate(now); tExpire = new PwDate(NEVER_EXPIRE); } - } - + /** * @return the actual password byte array. */ @@ -281,7 +280,6 @@ public class PwEntryV3 extends PwEntry { return true; } - @Override public void assign(PwEntry source) { diff --git a/app/src/main/java/com/keepassdroid/database/PwEntryV4.java b/app/src/main/java/com/keepassdroid/database/PwEntryV4.java index 667709f4f..9a3ae3bf0 100644 --- a/app/src/main/java/com/keepassdroid/database/PwEntryV4.java +++ b/app/src/main/java/com/keepassdroid/database/PwEntryV4.java @@ -19,19 +19,21 @@ */ package com.keepassdroid.database; +import com.keepassdroid.database.security.ProtectedBinary; +import com.keepassdroid.database.security.ProtectedString; +import com.keepassdroid.utils.SprEngine; + +import java.io.Serializable; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.UUID; -import com.keepassdroid.database.security.ProtectedBinary; -import com.keepassdroid.database.security.ProtectedString; -import com.keepassdroid.utils.SprEngine; - public class PwEntryV4 extends PwEntry implements ITimeLogger { public static final String STR_TITLE = "Title"; public static final String STR_USERNAME = "UserName"; @@ -41,14 +43,14 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger { public PwGroupV4 parent; public UUID uuid = PwDatabaseV4.UUID_ZERO; - public HashMap strings = new HashMap(); - public HashMap binaries = new HashMap(); + private HashMap fields = new HashMap<>(); + public HashMap binaries = new HashMap<>(); public PwIconCustom customIcon = PwIconCustom.ZERO; public String foregroundColor = ""; public String backgroupColor = ""; public String overrideURL = ""; public AutoType autoType = new AutoType(); - public ArrayList history = new ArrayList(); + public ArrayList history = new ArrayList<>(); private Date parentGroupLastMod = PwDatabaseV4.DEFAULT_NOW; private Date creation = PwDatabaseV4.DEFAULT_NOW; @@ -62,7 +64,7 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger { public String tags = ""; public Map customData = new HashMap(); - public class AutoType implements Cloneable { + public class AutoType implements Cloneable, Serializable { private static final long OBF_OPT_NONE = 0; public boolean enabled = true; @@ -123,28 +125,18 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger { } } + @SuppressWarnings("unchecked") @Override public PwEntry clone(boolean deepStrings) { PwEntryV4 entry = (PwEntryV4) super.clone(deepStrings); if (deepStrings) { - entry.strings = (HashMap) strings.clone(); + entry.fields = (HashMap) fields.clone(); } return entry; } - - @SuppressWarnings("unchecked") - public PwEntryV4 cloneDeep() { - PwEntryV4 entry = (PwEntryV4) clone(true); - - entry.binaries = (HashMap) binaries.clone(); - entry.history = (ArrayList) history.clone(); - entry.autoType = (AutoType) autoType.clone(); - - return entry; - } @Override public void assign(PwEntry source) { @@ -162,7 +154,7 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger { private void assign(PwEntryV4 source) { parent = source.parent; uuid = source.uuid; - strings = source.strings; + fields = source.fields; binaries = source.binaries; customIcon = source.customIcon; foregroundColor = source.foregroundColor; @@ -313,7 +305,7 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger { } public String getString(String key) { - ProtectedString value = strings.get(key); + ProtectedString value = fields.get(key); if ( value == null ) return new String(""); @@ -322,7 +314,7 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger { public void setString(String key, String value, boolean protect) { ProtectedString ps = new ProtectedString(protect, value); - strings.put(key, ps); + fields.put(key, ps); } public Date getLocationChanged() { @@ -367,22 +359,26 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger { } else { return customIcon; } - - } - - public static boolean IsStandardString(String key) { - return key.equals(STR_TITLE) || key.equals(STR_USERNAME) - || key.equals(STR_PASSWORD) || key.equals(STR_URL) - || key.equals(STR_NOTES); } public void createBackup(PwDatabaseV4 db) { PwEntryV4 copy = cloneDeep(); - copy.history = new ArrayList(); + copy.history = new ArrayList<>(); history.add(copy); if (db != null) maintainBackups(db); } + + @SuppressWarnings("unchecked") + public PwEntryV4 cloneDeep() { + PwEntryV4 entry = (PwEntryV4) clone(true); + + entry.binaries = (HashMap) binaries.clone(); + entry.history = (ArrayList) history.clone(); + entry.autoType = (AutoType) autoType.clone(); + + return entry; + } private boolean maintainBackups(PwDatabaseV4 db) { boolean deleted = false; @@ -432,13 +428,73 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger { history.remove(index); } } - + + @Override + public boolean allowExtraFields() { + return true; + } + + public Map getFields() { + return fields; + } + + @Override + public Map getExtraProtectedFields() { + Map protectedFields = super.getExtraProtectedFields(); + if (fields.size() > 0) { + for (Map.Entry pair : fields.entrySet()) { + String key = pair.getKey(); + if (!PwEntryV4.IsStandardField(key)) { + protectedFields.put(key, pair.getValue()); + } + } + } + return protectedFields; + } + + @Override + public Map getExtraFields(PwDatabase pm) { + Map extraFields = super.getExtraFields(pm); + SprEngine spr = SprEngine.getInstance(pm); + // Display custom fields + if (fields.size() > 0) { + for (Map.Entry pair : fields.entrySet()) { + String key = pair.getKey(); + // TODO Add hidden style for protection field + if (!PwEntryV4.IsStandardField(key)) { + extraFields.put(key, spr.compile(pair.getValue().toString(), this, pm)); + } + } + } + return extraFields; + } + + public static boolean IsStandardField(String key) { + return key.equals(STR_TITLE) || key.equals(STR_USERNAME) + || key.equals(STR_PASSWORD) || key.equals(STR_URL) + || key.equals(STR_NOTES); + } + + public void addField(String label, ProtectedString value) { + fields.put(label, value); + } + + @Override + public void removeExtraFields() { + Iterator> iter = fields.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry pair = iter.next(); + if (!PwEntryV4.IsStandardField(pair.getKey())) { + iter.remove(); + } + } + } private static final long FIXED_LENGTH_SIZE = 128; // Approximate fixed length size public long getSize() { long size = FIXED_LENGTH_SIZE; - for (Entry pair : strings.entrySet()) { + for (Entry pair : fields.entrySet()) { size += pair.getKey().length(); size += pair.getValue().length(); } diff --git a/app/src/main/java/com/keepassdroid/database/PwGroup.java b/app/src/main/java/com/keepassdroid/database/PwGroup.java index 2d317dfab..f9f7718a0 100644 --- a/app/src/main/java/com/keepassdroid/database/PwGroup.java +++ b/app/src/main/java/com/keepassdroid/database/PwGroup.java @@ -19,75 +19,117 @@ */ package com.keepassdroid.database; +import com.keepassdroid.utils.StrUtil; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; -import com.keepassdroid.utils.StrUtil; +public abstract class PwGroup extends PwNode { -public abstract class PwGroup { - public List childGroups = new ArrayList(); - public List childEntries = new ArrayList(); + // TODO Change dependency and make private + public List childGroups = new ArrayList<>(); + public List childEntries = new ArrayList<>(); public String name = ""; public PwIconStandard icon; - public abstract PwGroup getParent(); - public abstract void setParent(PwGroup parent); - + private List children = new ArrayList<>(); + + public void initNewGroup(String nm, PwGroupId newId) { + setId(newId); + name = nm; + } + + public void addChildGroup(PwGroup group) { + this.childGroups.add(group); + } + + public void addChildEntry(PwEntry entry) { + this.childEntries.add(entry); + } + + public void removeChildGroup(PwGroup group) { + this.childGroups.remove(group); + } + + public void removeChildEntry(PwEntry entry) { + this.childEntries.remove(entry); + } + + public int numbersOfChildGroups() { + return childGroups.size(); + } + + public int numbersOfChildEntries() { + return childEntries.size(); + } + + @Override + public Type getType() { + return Type.GROUP; + } + + /** + * Filter MetaStream entries and return children + * @return List of direct children (one level below) as PwNode + */ + public List getDirectChildren() { + children.clear(); + children.addAll(childGroups); + for(PwEntry child : childEntries) { + if (!child.isMetaStream()) + children.add(child); + } + return children; + } + + /** + * Number of direct elements in Node (one level below) + * @return Size of child elements, default is 0 + */ + public int numberOfDirectChildren() { + return childGroups.size() + childEntries.size(); + } + + public boolean isContainedIn(PwGroup container) { + PwGroup cur = this; + while (cur != null) { + if (cur == container) { + return true; + } + cur = cur.getParent(); + } + return false; + } + public abstract PwGroupId getId(); public abstract void setId(PwGroupId id); - public abstract String getName(); + @Override + public String getDisplayTitle() { + return getName(); + } + + public abstract String getName(); public abstract Date getLastMod(); public PwIcon getIcon() { return icon; } - - public void sortGroupsByName() { - Collections.sort(childGroups, new GroupNameComparator()); - } - - public static class GroupNameComparator implements Comparator { - - public int compare(PwGroup object1, PwGroup object2) { - return object1.getName().compareToIgnoreCase(object2.getName()); - } - - } public abstract void setLastAccessTime(Date date); public abstract void setLastModificationTime(Date date); - - public void sortEntriesByName() { - Collections.sort(childEntries, new PwEntry.EntryNameComparator()); - } - - public void initNewGroup(String nm, PwGroupId newId) { - setId(newId); - name = nm; - } - - public boolean isContainedIn(PwGroup container) { - PwGroup cur = this; - while (cur != null) { - if (cur == container) { - return true; - } - - cur = cur.getParent(); - } - + + public boolean allowAddEntryIfIsRoot() { return false; } public void touch(boolean modified, boolean touchParents) { Date now = new Date(); - setLastAccessTime(now); if (modified) { @@ -100,7 +142,6 @@ public abstract class PwGroup { } } - public void searchEntries(SearchParameters sp, List listStorage) { if (sp == null) { return; } if (listStorage == null) { return; } @@ -147,7 +188,6 @@ public abstract class PwGroup { complement.add(entry); } } - pg = complement; } else { @@ -181,19 +221,94 @@ public abstract class PwGroup { if (entryHandler != null) { for (PwEntry entry : childEntries) { if (!entryHandler.operate(entry)) return false; - } } for (PwGroup group : childGroups) { - if ((groupHandler != null) && !groupHandler.operate(group)) return false; - group.preOrderTraverseTree(groupHandler, entryHandler); } - return true; - } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PwGroup pwGroup = (PwGroup) o; + return isSameType(pwGroup) + && (getId() != null ? getId().equals(pwGroup.getId()) : pwGroup.getId() == null); + } + + @Override + public int hashCode() { + PwGroupId groupId = getId(); + return groupId != null ? groupId.hashCode() : 0; + } + + /** + * Group comparator by name + */ + public static class GroupNameComparator implements Comparator { + + private boolean ascending; + + public GroupNameComparator() { + this(true); + } + + public GroupNameComparator(boolean ascending) { + this.ascending = ascending; + } + + public int compare(PwGroup object1, PwGroup object2) { + if (object1.equals(object2)) + return 0; + + int groupNameComp = object1.getName().compareToIgnoreCase(object2.getName()); + // If same name, can be different + if (groupNameComp == 0) { + return object1.hashCode() - object2.hashCode(); + } + // If descending + if (!ascending) + groupNameComp = -groupNameComp; + + return groupNameComp; + } + } + + /** + * Group comparator by name + */ + public static class GroupCreationComparator implements Comparator { + + private boolean ascending; + + public GroupCreationComparator() { + this(true); + } + + public GroupCreationComparator(boolean ascending) { + this.ascending = ascending; + } + + public int compare(PwGroup object1, PwGroup object2) { + if (object1.equals(object2)) + return 0; + + int groupCreationComp = object1.getCreationTime().compareTo(object2.getCreationTime()); + // If same creation, can be different + if (groupCreationComp == 0) { + return object1.hashCode() - object2.hashCode(); + } + // If descending + if (!ascending) + groupCreationComp = -groupCreationComp; + + return groupCreationComp; + } + } } diff --git a/app/src/main/java/com/keepassdroid/database/PwGroupId.java b/app/src/main/java/com/keepassdroid/database/PwGroupId.java index 793959326..4284618e2 100644 --- a/app/src/main/java/com/keepassdroid/database/PwGroupId.java +++ b/app/src/main/java/com/keepassdroid/database/PwGroupId.java @@ -1,5 +1,7 @@ package com.keepassdroid.database; -public abstract class PwGroupId { +import java.io.Serializable; + +public abstract class PwGroupId implements Serializable { } diff --git a/app/src/main/java/com/keepassdroid/database/PwGroupIdV3.java b/app/src/main/java/com/keepassdroid/database/PwGroupIdV3.java index 53f767939..d5bfc17f8 100644 --- a/app/src/main/java/com/keepassdroid/database/PwGroupIdV3.java +++ b/app/src/main/java/com/keepassdroid/database/PwGroupIdV3.java @@ -39,7 +39,7 @@ public class PwGroupIdV3 extends PwGroupId { @Override public int hashCode() { - Integer i = Integer.valueOf(id); + Integer i = id; return i.hashCode(); } diff --git a/app/src/main/java/com/keepassdroid/database/PwGroupV3.java b/app/src/main/java/com/keepassdroid/database/PwGroupV3.java index 5ef90d1e1..ed59db4d9 100644 --- a/app/src/main/java/com/keepassdroid/database/PwGroupV3.java +++ b/app/src/main/java/com/keepassdroid/database/PwGroupV3.java @@ -30,12 +30,15 @@ Copyright 2006 Bill Zwicky package com.keepassdroid.database; +import android.content.Intent; +import android.os.Bundle; + +import com.keepassdroid.utils.Types; + import java.util.Calendar; import java.util.Date; import java.util.List; - - /** * @author Brian Pellin * @author Naomaru Itoi @@ -43,8 +46,6 @@ import java.util.List; * @author Dominik Reichl */ public class PwGroupV3 extends PwGroup { - public PwGroupV3() { - } public String toString() { return name; @@ -155,4 +156,11 @@ public class PwGroupV3 extends PwGroup { tLastMod = new PwDate(date); } + @Override + public Date getCreationTime() { + if(tCreation != null) + return tCreation.getJDate(); + else + return new Date(); + } } diff --git a/app/src/main/java/com/keepassdroid/database/PwGroupV4.java b/app/src/main/java/com/keepassdroid/database/PwGroupV4.java index 63871fdaa..3592e79dc 100644 --- a/app/src/main/java/com/keepassdroid/database/PwGroupV4.java +++ b/app/src/main/java/com/keepassdroid/database/PwGroupV4.java @@ -48,9 +48,7 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger { private long usageCount = 0; public Map customData = new HashMap(); - public PwGroupV4() { - - } + public PwGroupV4() {} public PwGroupV4(boolean createUUID, boolean setTimes, String name, PwIconStandard icon) { if (createUUID) { @@ -64,7 +62,14 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger { this.name = name; this.icon = icon; } - + + @Override + public void initNewGroup(String nm, PwGroupId newId) { + super.initNewGroup(nm, newId); + + lastAccess = lastMod = creation = parentGroupLastMod = new Date(); + } + public void AddGroup(PwGroupV4 subGroup, boolean takeOwnership) { AddGroup(subGroup, takeOwnership, false); } @@ -86,8 +91,8 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger { public void AddEntry(PwEntryV4 pe, boolean takeOwnership, boolean updateLocationChanged) { assert(pe != null); - - childEntries.add(pe); + + addChildEntry(pe); if ( takeOwnership ) pe.parent = this; @@ -102,7 +107,7 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger { public void buildChildGroupsRecursive(List list) { list.add(this); - for ( int i = 0; i < childGroups.size(); i++) { + for ( int i = 0; i < numbersOfChildGroups(); i++) { PwGroupV4 child = (PwGroupV4) childGroups.get(i); child.buildChildGroupsRecursive(list); @@ -110,11 +115,11 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger { } public void buildChildEntriesRecursive(List list) { - for ( int i = 0; i < childEntries.size(); i++ ) { + for ( int i = 0; i < numbersOfChildEntries(); i++ ) { list.add(childEntries.get(i)); } - for ( int i = 0; i < childGroups.size(); i++ ) { + for ( int i = 0; i < numbersOfChildGroups(); i++ ) { PwGroupV4 child = (PwGroupV4) childGroups.get(i); child.buildChildEntriesRecursive(list); } @@ -168,7 +173,6 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger { public void setCreationTime(Date date) { creation = date; - } public void setExpiryTime(Date date) { @@ -204,7 +208,11 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger { @Override public void setParent(PwGroup prt) { parent = (PwGroupV4) prt; - + } + + @Override + public boolean allowAddEntryIfIsRoot() { + return true; } @Override @@ -216,13 +224,6 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger { } } - @Override - public void initNewGroup(String nm, PwGroupId newId) { - super.initNewGroup(nm, newId); - - lastAccess = lastMod = creation = parentGroupLastMod = new Date(); - } - public boolean isSearchEnabled() { PwGroupV4 group = this; while (group != null) { diff --git a/app/src/main/java/com/keepassdroid/database/PwIcon.java b/app/src/main/java/com/keepassdroid/database/PwIcon.java index 798ad2528..65fa67fd7 100644 --- a/app/src/main/java/com/keepassdroid/database/PwIcon.java +++ b/app/src/main/java/com/keepassdroid/database/PwIcon.java @@ -1,6 +1,8 @@ package com.keepassdroid.database; -public abstract class PwIcon { +import java.io.Serializable; + +public abstract class PwIcon implements Serializable { public boolean isMetaStreamIcon() { return false; diff --git a/app/src/main/java/com/keepassdroid/database/PwNode.java b/app/src/main/java/com/keepassdroid/database/PwNode.java new file mode 100644 index 000000000..77ea64bd0 --- /dev/null +++ b/app/src/main/java/com/keepassdroid/database/PwNode.java @@ -0,0 +1,88 @@ +/* + * Copyright 2018 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.database; + +import java.io.Serializable; +import java.util.Date; + +/** + * Abstract class who manage Groups and Entries + */ +public abstract class PwNode implements Serializable { + + /** + * Type of available Nodes + */ + public enum Type { + GROUP, ENTRY + } + + /** + * @return Type of Node + */ + public abstract Type getType(); + + /** + * @return Title to display as view + */ + public abstract String getDisplayTitle(); + + /** + * @return Visual icon + */ + public abstract PwIcon getIcon(); + + /** + * @return Creation date and time of the node + */ + public abstract Date getCreationTime(); + + /** + * Retrieve the parent node + * @return PwGroup parent as group + */ + public abstract PwGroup getParent(); + + /** + * Assign a parent to this node + */ + public abstract void setParent(PwGroup parent); + + /** + * If the content (type, title, icon) is visually the same + * @param o Node to compare + * @return True if visually as o + */ + public boolean isContentVisuallyTheSame(PwNode o) { + return getType().equals(o.getType()) + && getDisplayTitle().equals(o.getDisplayTitle()) + && getIcon().equals(o.getIcon()); + } + + /** + * Define if it's the same type of another node + * @param otherNode The other node to test + * @return true if both have the same type + */ + boolean isSameType(PwNode otherNode) { + return getType() != null ? getType().equals(otherNode.getType()) : otherNode.getType() == null; + } +} diff --git a/app/src/main/java/com/keepassdroid/database/PwVersion.java b/app/src/main/java/com/keepassdroid/database/PwVersion.java new file mode 100644 index 000000000..74707b6f8 --- /dev/null +++ b/app/src/main/java/com/keepassdroid/database/PwVersion.java @@ -0,0 +1,5 @@ +package com.keepassdroid.database; + +public enum PwVersion { + V3, V4 +} diff --git a/app/src/main/java/com/keepassdroid/database/SortNodeEnum.java b/app/src/main/java/com/keepassdroid/database/SortNodeEnum.java new file mode 100644 index 000000000..6576e8e62 --- /dev/null +++ b/app/src/main/java/com/keepassdroid/database/SortNodeEnum.java @@ -0,0 +1,176 @@ +/* + * Copyright 2018 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.database; + +import java.util.Comparator; + +public enum SortNodeEnum { + DB, TITLE, USERNAME, CREATION_TIME, LAST_MODIFY_TIME, LAST_ACCESS_TIME; + + public Comparator getNodeComparator(boolean ascending, boolean groupsBefore) { + switch (this) { + case DB: + return new NodeCreationComparator(ascending, groupsBefore); // TODO Sort + default: + case TITLE: + return new NodeTitleComparator(ascending, groupsBefore); + case USERNAME: + return new NodeCreationComparator(ascending, groupsBefore); // TODO Sort + case CREATION_TIME: + return new NodeCreationComparator(ascending, groupsBefore); + case LAST_MODIFY_TIME: + return new NodeCreationComparator(ascending, groupsBefore); // TODO Sort + case LAST_ACCESS_TIME: + return new NodeCreationComparator(ascending, groupsBefore); // TODO Sort + } + } + + private static abstract class NodeComparator implements Comparator { + boolean ascending; + boolean groupsBefore; + + NodeComparator() { + this(true, true); + } + + NodeComparator(boolean groupsBefore) { + this(true, groupsBefore); + } + + NodeComparator(boolean ascending, boolean groupsBefore) { + this.ascending = ascending; + this.groupsBefore = groupsBefore; + } + } + + /** + * Comparator of Node by Title, Groups first, Entries second + */ + public static class NodeTitleComparator extends NodeComparator { + + public NodeTitleComparator() { + super(); + } + + public NodeTitleComparator(boolean groupsBefore) { + super(groupsBefore); + } + + public NodeTitleComparator(boolean ascending, boolean groupsBefore) { + super(ascending, groupsBefore); + } + + public int compare(PwNode object1, PwNode object2) { + if (object1.equals(object2)) + return 0; + + if (object1 instanceof PwGroup) { + if (object2 instanceof PwGroup) { + return new PwGroup.GroupNameComparator(ascending) + .compare((PwGroup) object1, (PwGroup) object2); + } else if (object2 instanceof PwEntry) { + if(groupsBefore) + return -1; + else + return 1; + } else { + return -1; + } + } else if (object1 instanceof PwEntry) { + if(object2 instanceof PwEntry) { + return new PwEntry.EntryNameComparator(ascending) + .compare((PwEntry) object1, (PwEntry) object2); + } else if (object2 instanceof PwGroup) { + if(groupsBefore) + return 1; + else + return -1; + } else { + return -1; + } + } + int nodeNameComp = object1.getDisplayTitle() + .compareToIgnoreCase(object2.getDisplayTitle()); + // If same name, can be different + if (nodeNameComp == 0) + return object1.hashCode() - object2.hashCode(); + return nodeNameComp; + } + } + + /** + * Comparator of node by creation, Groups first, Entries second + */ + public static class NodeCreationComparator extends NodeComparator { + + public NodeCreationComparator() { + super(); + } + + public NodeCreationComparator(boolean groupsBefore) { + super(groupsBefore); + } + + + public NodeCreationComparator(boolean ascending, boolean groupsBefore) { + super(ascending, groupsBefore); + } + + @Override + public int compare(PwNode object1, PwNode object2) { + if (object1.equals(object2)) + return 0; + + if (object1 instanceof PwGroup) { + if (object2 instanceof PwGroup) { + return new PwGroup.GroupCreationComparator(ascending) + .compare((PwGroup) object1, (PwGroup) object2); + } else if (object2 instanceof PwEntry) { + if(groupsBefore) + return -1; + else + return 1; + } else { + return -1; + } + } else if (object1 instanceof PwEntry) { + if(object2 instanceof PwEntry) { + return new PwEntry.EntryCreationComparator(ascending) + .compare((PwEntry) object1, (PwEntry) object2); + } else if (object2 instanceof PwGroup) { + if(groupsBefore) + return 1; + else + return -1; + } else { + return -1; + } + } + int nodeCreationComp = object1.getCreationTime() + .compareTo(object2.getCreationTime()); + // If same creation, can be different + if (nodeCreationComp == 0) { + return object1.hashCode() - object2.hashCode(); + } + return nodeCreationComp; + } + } +} diff --git a/app/src/main/java/com/keepassdroid/database/edit/AddEntry.java b/app/src/main/java/com/keepassdroid/database/edit/AddEntry.java index 57c22f74a..4535fea6c 100644 --- a/app/src/main/java/com/keepassdroid/database/edit/AddEntry.java +++ b/app/src/main/java/com/keepassdroid/database/edit/AddEntry.java @@ -21,21 +21,16 @@ package com.keepassdroid.database.edit; import android.content.Context; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.database.PwDatabase; import com.keepassdroid.database.PwEntry; -import com.keepassdroid.database.PwGroup; public class AddEntry extends RunnableOnFinish { protected Database mDb; private PwEntry mEntry; private Context ctx; - public static AddEntry getInstance(Context ctx, Database db, PwEntry entry, OnFinish finish) { - return new AddEntry(ctx, db, entry, finish); - } - - protected AddEntry(Context ctx, Database db, PwEntry entry, OnFinish finish) { + public AddEntry(Context ctx, Database db, PwEntry entry, OnFinish finish) { super(finish); mDb = db; @@ -56,27 +51,18 @@ public class AddEntry extends RunnableOnFinish { private class AfterAdd extends OnFinish { - public AfterAdd(OnFinish finish) { + AfterAdd(OnFinish finish) { super(finish); } @Override public void run() { PwDatabase pm = mDb.pm; - if ( mSuccess ) { - - PwGroup parent = mEntry.getParent(); - - // Mark parent tree dirty - mDb.dirty.add(parent); - - } else { + if ( !mSuccess ) { pm.removeEntryFrom(mEntry, mEntry.getParent()); } - + // TODO if add entry callback super.run(); } } - - } diff --git a/app/src/main/java/com/keepassdroid/database/edit/AddGroup.java b/app/src/main/java/com/keepassdroid/database/edit/AddGroup.java index 31dbe1eba..1bf3bd94c 100644 --- a/app/src/main/java/com/keepassdroid/database/edit/AddGroup.java +++ b/app/src/main/java/com/keepassdroid/database/edit/AddGroup.java @@ -21,7 +21,7 @@ package com.keepassdroid.database.edit; import android.content.Context; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.database.PwDatabase; import com.keepassdroid.database.PwGroup; @@ -32,24 +32,20 @@ public class AddGroup extends RunnableOnFinish { private PwGroup mGroup; private PwGroup mParent; private Context ctx; - protected boolean mDontSave; + private boolean mDontSave; - - public static AddGroup getInstance(Context ctx, Database db, String name, int iconid, PwGroup parent, OnFinish finish, boolean dontSave) { - return new AddGroup(ctx, db, name, iconid, parent, finish, dontSave); - } - - - private AddGroup(Context ctx, Database db, String name, int iconid, PwGroup parent, OnFinish finish, boolean dontSave) { - super(finish); - + public AddGroup(Context ctx, Database db, String name, int iconid, + PwGroup parent, AfterAddNodeOnFinish afterAddNode, + boolean dontSave) { + super(afterAddNode); + mDb = db; mName = name; mIconID = iconid; mParent = parent; mDontSave = dontSave; this.ctx = ctx; - + mFinish = new AfterAdd(mFinish); } @@ -62,9 +58,7 @@ public class AddGroup extends RunnableOnFinish { mGroup.initNewGroup(mName, pm.newGroupId()); mGroup.icon = mDb.pm.iconFactory.getIcon(mIconID); pm.addGroupTo(mGroup, mParent); - - //mParent.sortGroupsByName(); - + // Commit to disk SaveDB save = new SaveDB(ctx, mDb, mFinish, mDontSave); save.run(); @@ -72,24 +66,23 @@ public class AddGroup extends RunnableOnFinish { private class AfterAdd extends OnFinish { - public AfterAdd(OnFinish finish) { + AfterAdd(OnFinish finish) { super(finish); } @Override public void run() { PwDatabase pm = mDb.pm; - if ( mSuccess ) { - // Mark parent group dirty - mDb.dirty.add(mParent); - } else { - pm.removeGroupFrom(mGroup, mParent); + if ( !mSuccess ) { + pm.removeGroupFrom(mGroup, mParent); } - - super.run(); + + // TODO Better callback + AfterAddNodeOnFinish afterAddNode = + (AfterAddNodeOnFinish) super.mOnFinish; + afterAddNode.mSuccess = mSuccess; + afterAddNode.mMessage = mMessage; + afterAddNode.run(mGroup); } - } - - } diff --git a/app/src/main/java/com/keepassdroid/database/edit/AfterAddNodeOnFinish.java b/app/src/main/java/com/keepassdroid/database/edit/AfterAddNodeOnFinish.java new file mode 100644 index 000000000..091822da5 --- /dev/null +++ b/app/src/main/java/com/keepassdroid/database/edit/AfterAddNodeOnFinish.java @@ -0,0 +1,13 @@ +package com.keepassdroid.database.edit; + +import android.os.Handler; + +import com.keepassdroid.database.PwNode; + +public abstract class AfterAddNodeOnFinish extends OnFinish { + public AfterAddNodeOnFinish(Handler handler) { + super(handler); + } + + public abstract void run(PwNode pwNode); +} diff --git a/app/src/main/java/com/keepassdroid/database/edit/CreateDB.java b/app/src/main/java/com/keepassdroid/database/edit/CreateDB.java index 5217e257f..659f8cb3c 100644 --- a/app/src/main/java/com/keepassdroid/database/edit/CreateDB.java +++ b/app/src/main/java/com/keepassdroid/database/edit/CreateDB.java @@ -21,7 +21,7 @@ package com.keepassdroid.database.edit; import android.content.Context; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.app.App; import com.keepassdroid.database.PwDatabase; import com.keepassdroid.utils.UriUtil; diff --git a/app/src/main/java/com/keepassdroid/database/edit/DeleteEntry.java b/app/src/main/java/com/keepassdroid/database/edit/DeleteEntry.java index 96fc5dc67..f0c414018 100644 --- a/app/src/main/java/com/keepassdroid/database/edit/DeleteEntry.java +++ b/app/src/main/java/com/keepassdroid/database/edit/DeleteEntry.java @@ -21,7 +21,7 @@ package com.keepassdroid.database.edit; import android.content.Context; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.database.PwDatabase; import com.keepassdroid.database.PwEntry; import com.keepassdroid.database.PwGroup; @@ -71,8 +71,6 @@ public class DeleteEntry extends RunnableOnFinish { // Commit database SaveDB save = new SaveDB(ctx, mDb, mFinish, mDontSave); save.run(); - - } private class AfterDelete extends OnFinish { @@ -81,7 +79,7 @@ public class DeleteEntry extends RunnableOnFinish { private PwEntry mEntry; private boolean recycled; - public AfterDelete(OnFinish finish, PwGroup parent, PwEntry entry, boolean r) { + AfterDelete(OnFinish finish, PwGroup parent, PwEntry entry, boolean r) { super(finish); mParent = parent; @@ -92,18 +90,7 @@ public class DeleteEntry extends RunnableOnFinish { @Override public void run() { PwDatabase pm = mDb.pm; - if ( mSuccess ) { - // Mark parent dirty - if ( mParent != null ) { - mDb.dirty.add(mParent); - } - - if (recycled) { - PwGroup recycleBin = pm.getRecycleBin(); - mDb.dirty.add(recycleBin); - mDb.dirty.add(mDb.pm.rootGroup); - } - } else { + if ( !mSuccess ) { if (recycled) { pm.undoRecycle(mEntry, mParent); } @@ -111,11 +98,9 @@ public class DeleteEntry extends RunnableOnFinish { pm.undoDeleteEntry(mEntry, mParent); } } + // TODO Callback after delete entry super.run(); - } - } - } diff --git a/app/src/main/java/com/keepassdroid/database/edit/DeleteGroup.java b/app/src/main/java/com/keepassdroid/database/edit/DeleteGroup.java index 8477ee55e..342d4bcfe 100644 --- a/app/src/main/java/com/keepassdroid/database/edit/DeleteGroup.java +++ b/app/src/main/java/com/keepassdroid/database/edit/DeleteGroup.java @@ -19,109 +19,115 @@ */ package com.keepassdroid.database.edit; -import java.util.ArrayList; -import java.util.List; +import android.content.Context; -import com.keepassdroid.Database; -import com.keepassdroid.GroupBaseActivity; import com.keepassdroid.app.App; +import com.keepassdroid.database.Database; +import com.keepassdroid.database.PwDatabase; import com.keepassdroid.database.PwEntry; import com.keepassdroid.database.PwGroup; +import java.util.ArrayList; +import java.util.List; + public class DeleteGroup extends RunnableOnFinish { - + + private Context mContext; private Database mDb; private PwGroup mGroup; - private GroupBaseActivity mAct; private boolean mDontSave; - public DeleteGroup(Database db, PwGroup group, GroupBaseActivity act, OnFinish finish) { + public DeleteGroup(Context ctx, Database db, PwGroup group, OnFinish finish) { super(finish); - setMembers(db, group, act, false); - } - - public DeleteGroup(Database db, PwGroup group, GroupBaseActivity act, OnFinish finish, boolean dontSave) { - super(finish); - setMembers(db, group, act, dontSave); + setMembers(ctx, db, group, false); } + public DeleteGroup(Context ctx, Database db, PwGroup group, OnFinish finish, boolean dontSave) { + super(finish); + setMembers(ctx, db, group, dontSave); + } public DeleteGroup(Database db, PwGroup group, OnFinish finish, boolean dontSave) { super(finish); - setMembers(db, group, null, dontSave); + setMembers(null, db, group, dontSave); } - private void setMembers(Database db, PwGroup group, GroupBaseActivity act, boolean dontSave) { + private void setMembers(Context ctx, Database db, PwGroup group, boolean dontSave) { mDb = db; mGroup = group; - mAct = act; + mContext = ctx; mDontSave = dontSave; - - mFinish = new AfterDelete(mFinish); } - - @Override public void run() { - - // Remove child entries - List childEnt = new ArrayList(mGroup.childEntries); - for ( int i = 0; i < childEnt.size(); i++ ) { - DeleteEntry task = new DeleteEntry(mAct, mDb, childEnt.get(i), null, true); - task.run(); - } - - // Remove child groups - List childGrp = new ArrayList(mGroup.childGroups); - for ( int i = 0; i < childGrp.size(); i++ ) { - DeleteGroup task = new DeleteGroup(mDb, childGrp.get(i), mAct, null, true); - task.run(); - } - - - // Remove from parent - PwGroup parent = mGroup.getParent(); - if ( parent != null ) { - parent.childGroups.remove(mGroup); - } - - // Remove from PwDatabaseV3 - mDb.pm.getGroups().remove(mGroup); - - // Save - SaveDB save = new SaveDB(mAct, mDb, mFinish, mDontSave); - save.run(); + PwDatabase pm = mDb.pm; + PwGroup parent = mGroup.getParent(); + // Remove Group from parent + boolean recycle = pm.canRecycle(mGroup); + if (recycle) { + pm.recycle(mGroup); + } + else { + // TODO tests + // Remove child entries + List childEnt = new ArrayList<>(mGroup.childEntries); + for ( int i = 0; i < childEnt.size(); i++ ) { + DeleteEntry task = new DeleteEntry(mContext, mDb, childEnt.get(i), null, true); + task.run(); + } + + // Remove child groups + List childGrp = new ArrayList<>(mGroup.childGroups); + for ( int i = 0; i < childGrp.size(); i++ ) { + DeleteGroup task = new DeleteGroup(mContext, mDb, childGrp.get(i), null, true); + task.run(); + } + pm.deleteGroup(mGroup); + + // Remove from PwDatabaseV3 + // TODO ENcapsulate + mDb.pm.getGroups().remove(mGroup); + } + + // Save + mFinish = new AfterDelete(mFinish, parent, mGroup, recycle); + + // Commit Database + SaveDB save = new SaveDB(mContext, mDb, mFinish, mDontSave); + save.run(); } private class AfterDelete extends OnFinish { - public AfterDelete(OnFinish finish) { + + private PwGroup mParent; + private PwGroup mGroup; + private boolean recycled; + + AfterDelete(OnFinish finish, PwGroup parent, PwGroup mGroup, boolean recycle) { super(finish); + + this.mParent = parent; + this.mGroup = mGroup; + this.recycled = recycle; } public void run() { - if ( mSuccess ) { - // Remove from tree global - mDb.pm.groups.remove(mGroup.getId()); - - // Remove tree from the dirty global (if it is present), not a big deal if this fails - mDb.dirty.remove(mGroup); - - // Mark parent dirty - PwGroup parent = mGroup.getParent(); - if ( parent != null ) { - mDb.dirty.add(parent); - } - mDb.dirty.add(mDb.pm.rootGroup); - } else { - // Let's not bother recovering from a failure to save a deleted tree. It is too much work. - App.setShutdown(); - } - + PwDatabase pm = mDb.pm; + if ( !mSuccess ) { + if (recycled) { + pm.undoRecycle(mGroup, mParent); + } + else { + // Let's not bother recovering from a failure to save a deleted tree. It is too much work. + App.setShutdown(); + // TODO TEST pm.undoDeleteGroup(mGroup, mParent); + } + } + // TODO Callback after delete group + super.run(); - } - } } diff --git a/app/src/main/java/com/keepassdroid/database/edit/LoadDB.java b/app/src/main/java/com/keepassdroid/database/edit/LoadDB.java index 918d6e393..da19c8ece 100644 --- a/app/src/main/java/com/keepassdroid/database/edit/LoadDB.java +++ b/app/src/main/java/com/keepassdroid/database/edit/LoadDB.java @@ -25,7 +25,7 @@ import android.net.Uri; import android.preference.PreferenceManager; import com.kunzisoft.keepass.R; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.app.App; import com.keepassdroid.database.exception.ArcFourException; import com.keepassdroid.database.exception.ContentFileNotFoundException; @@ -104,6 +104,9 @@ public class LoadDB extends RunnableOnFinish { } catch (OutOfMemoryError e) { finish(false, mCtx.getString(R.string.error_out_of_memory)); return; + } catch (Exception e) { + finish(false, e.getMessage()); + return; } finish(true); diff --git a/app/src/main/java/com/keepassdroid/database/edit/RunnableOnFinish.java b/app/src/main/java/com/keepassdroid/database/edit/RunnableOnFinish.java index 842d6e0cc..54f5040dd 100644 --- a/app/src/main/java/com/keepassdroid/database/edit/RunnableOnFinish.java +++ b/app/src/main/java/com/keepassdroid/database/edit/RunnableOnFinish.java @@ -19,7 +19,7 @@ */ package com.keepassdroid.database.edit; -import com.keepassdroid.UpdateStatus; +import com.keepassdroid.tasks.UpdateStatus; public abstract class RunnableOnFinish implements Runnable { diff --git a/app/src/main/java/com/keepassdroid/database/edit/SaveDB.java b/app/src/main/java/com/keepassdroid/database/edit/SaveDB.java index 634a4bba4..2b981d4fd 100644 --- a/app/src/main/java/com/keepassdroid/database/edit/SaveDB.java +++ b/app/src/main/java/com/keepassdroid/database/edit/SaveDB.java @@ -23,7 +23,7 @@ import android.content.Context; import java.io.IOException; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.database.exception.PwDbOutputException; public class SaveDB extends RunnableOnFinish { diff --git a/app/src/main/java/com/keepassdroid/database/edit/SetPassword.java b/app/src/main/java/com/keepassdroid/database/edit/SetPassword.java index d19a5cfe0..bce5df610 100644 --- a/app/src/main/java/com/keepassdroid/database/edit/SetPassword.java +++ b/app/src/main/java/com/keepassdroid/database/edit/SetPassword.java @@ -23,7 +23,7 @@ import android.content.Context; import android.content.DialogInterface; import android.net.Uri; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.database.PwDatabase; import com.keepassdroid.database.exception.InvalidKeyFileException; import com.keepassdroid.dialog.PasswordEncodingDialogHelper; diff --git a/app/src/main/java/com/keepassdroid/database/edit/UpdateEntry.java b/app/src/main/java/com/keepassdroid/database/edit/UpdateEntry.java index 03278a051..b54294ba0 100644 --- a/app/src/main/java/com/keepassdroid/database/edit/UpdateEntry.java +++ b/app/src/main/java/com/keepassdroid/database/edit/UpdateEntry.java @@ -21,9 +21,8 @@ package com.keepassdroid.database.edit; import android.content.Context; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.database.PwEntry; -import com.keepassdroid.database.PwGroup; public class UpdateEntry extends RunnableOnFinish { private Database mDb; @@ -61,36 +60,19 @@ public class UpdateEntry extends RunnableOnFinish { private class AfterUpdate extends OnFinish { private PwEntry mBackup; - public AfterUpdate(PwEntry backup, OnFinish finish) { + AfterUpdate(PwEntry backup, OnFinish finish) { super(finish); - mBackup = backup; } @Override public void run() { - if ( mSuccess ) { - // Mark group dirty if title or icon changes - if ( ! mBackup.getTitle().equals(mNewE.getTitle()) || ! mBackup.getIcon().equals(mNewE.getIcon()) ) { - PwGroup parent = mBackup.getParent(); - if ( parent != null ) { - // Resort entries - parent.sortEntriesByName(); - - // Mark parent group dirty - mDb.dirty.add(parent); - - } - } - } else { + if ( !mSuccess ) { // If we fail to save, back out changes to global structure mOldE.assign(mBackup); } - + // TODO Callback for update entry super.run(); } - } - - } diff --git a/app/src/main/java/com/keepassdroid/database/iterator/EntrySearchStringIteratorV4.java b/app/src/main/java/com/keepassdroid/database/iterator/EntrySearchStringIteratorV4.java index e2282d531..78f46f5ee 100644 --- a/app/src/main/java/com/keepassdroid/database/iterator/EntrySearchStringIteratorV4.java +++ b/app/src/main/java/com/keepassdroid/database/iterator/EntrySearchStringIteratorV4.java @@ -35,14 +35,14 @@ public class EntrySearchStringIteratorV4 extends EntrySearchStringIterator { public EntrySearchStringIteratorV4(PwEntryV4 entry) { this.sp = SearchParametersV4.DEFAULT; - setIterator = entry.strings.entrySet().iterator(); + setIterator = entry.getFields().entrySet().iterator(); advance(); } public EntrySearchStringIteratorV4(PwEntryV4 entry, SearchParametersV4 sp) { this.sp = sp; - setIterator = entry.strings.entrySet().iterator(); + setIterator = entry.getFields().entrySet().iterator(); advance(); } diff --git a/app/src/main/java/com/keepassdroid/database/load/Importer.java b/app/src/main/java/com/keepassdroid/database/load/Importer.java index 6f0e101ee..1af6b6eca 100644 --- a/app/src/main/java/com/keepassdroid/database/load/Importer.java +++ b/app/src/main/java/com/keepassdroid/database/load/Importer.java @@ -22,7 +22,7 @@ package com.keepassdroid.database.load; import java.io.IOException; import java.io.InputStream; -import com.keepassdroid.UpdateStatus; +import com.keepassdroid.tasks.UpdateStatus; import com.keepassdroid.database.PwDatabase; import com.keepassdroid.database.exception.InvalidDBException; diff --git a/app/src/main/java/com/keepassdroid/database/load/ImporterV3.java b/app/src/main/java/com/keepassdroid/database/load/ImporterV3.java index 3dde66e91..6722512b7 100644 --- a/app/src/main/java/com/keepassdroid/database/load/ImporterV3.java +++ b/app/src/main/java/com/keepassdroid/database/load/ImporterV3.java @@ -66,7 +66,7 @@ import javax.crypto.spec.SecretKeySpec; import android.util.Log; import com.kunzisoft.keepass.R; -import com.keepassdroid.UpdateStatus; +import com.keepassdroid.tasks.UpdateStatus; import com.keepassdroid.crypto.CipherFactory; import com.keepassdroid.database.PwDatabaseV3; import com.keepassdroid.database.PwDate; diff --git a/app/src/main/java/com/keepassdroid/database/load/ImporterV3Debug.java b/app/src/main/java/com/keepassdroid/database/load/ImporterV3Debug.java index eb68026b2..8daaf3f79 100644 --- a/app/src/main/java/com/keepassdroid/database/load/ImporterV3Debug.java +++ b/app/src/main/java/com/keepassdroid/database/load/ImporterV3Debug.java @@ -22,7 +22,7 @@ package com.keepassdroid.database.load; import java.io.IOException; import java.io.InputStream; -import com.keepassdroid.UpdateStatus; +import com.keepassdroid.tasks.UpdateStatus; import com.keepassdroid.database.PwDatabaseV3Debug; import com.keepassdroid.database.exception.InvalidDBException; diff --git a/app/src/main/java/com/keepassdroid/database/load/ImporterV4.java b/app/src/main/java/com/keepassdroid/database/load/ImporterV4.java index d151266f7..7c81888ab 100644 --- a/app/src/main/java/com/keepassdroid/database/load/ImporterV4.java +++ b/app/src/main/java/com/keepassdroid/database/load/ImporterV4.java @@ -46,11 +46,10 @@ import org.xmlpull.v1.XmlPullParserFactory; import biz.source_code.base64Coder.Base64Coder; -import com.keepassdroid.UpdateStatus; +import com.keepassdroid.tasks.UpdateStatus; import com.keepassdroid.crypto.CipherFactory; import com.keepassdroid.crypto.PwStreamCipherFactory; import com.keepassdroid.crypto.engine.CipherEngine; -import com.keepassdroid.database.BinaryPool; import com.keepassdroid.database.ITimeLogger; import com.keepassdroid.database.PwCompressionAlgorithm; import com.keepassdroid.database.PwDatabaseV4; @@ -863,7 +862,7 @@ public class ImporterV4 extends Importer { } else if ( ctx == KdbContext.EntryTimes && name.equalsIgnoreCase(ElemTimes) ) { return KdbContext.Entry; } else if ( ctx == KdbContext.EntryString && name.equalsIgnoreCase(ElemString) ) { - ctxEntry.strings.put(ctxStringName, ctxStringValue); + ctxEntry.addField(ctxStringName, ctxStringValue); ctxStringName = null; ctxStringValue = null; diff --git a/app/src/main/java/com/keepassdroid/database/load/ImporterV4Debug.java b/app/src/main/java/com/keepassdroid/database/load/ImporterV4Debug.java index 5e6fc150c..12d8d4c57 100644 --- a/app/src/main/java/com/keepassdroid/database/load/ImporterV4Debug.java +++ b/app/src/main/java/com/keepassdroid/database/load/ImporterV4Debug.java @@ -19,7 +19,7 @@ */ package com.keepassdroid.database.load; -import com.keepassdroid.UpdateStatus; +import com.keepassdroid.tasks.UpdateStatus; import com.keepassdroid.database.PwDatabaseV4Debug; import com.keepassdroid.database.exception.InvalidDBException; diff --git a/app/src/main/java/com/keepassdroid/database/save/PwDbV3Output.java b/app/src/main/java/com/keepassdroid/database/save/PwDbV3Output.java index 891c276e3..3b2ac40d9 100644 --- a/app/src/main/java/com/keepassdroid/database/save/PwDbV3Output.java +++ b/app/src/main/java/com/keepassdroid/database/save/PwDbV3Output.java @@ -260,7 +260,7 @@ public class PwDbV3Output extends PwDbOutput { groupList.add(group); // Recurse over children - for ( int i = 0; i < group.childGroups.size(); i++ ) { + for ( int i = 0; i < group.numbersOfChildGroups(); i++ ) { sortGroup((PwGroupV3) group.childGroups.get(i), groupList); } } diff --git a/app/src/main/java/com/keepassdroid/database/save/PwDbV4Output.java b/app/src/main/java/com/keepassdroid/database/save/PwDbV4Output.java index 529cfa7b9..ea6ce6fd8 100644 --- a/app/src/main/java/com/keepassdroid/database/save/PwDbV4Output.java +++ b/app/src/main/java/com/keepassdroid/database/save/PwDbV4Output.java @@ -475,7 +475,7 @@ public class PwDbV4Output extends PwDbOutput { writeList(ElemTimes, entry); - writeList(entry.strings, true); + writeList(entry.getFields(), true); writeList(entry.binaries); writeList(ElemAutoType, entry.autoType); diff --git a/app/src/main/java/com/keepassdroid/database/security/ProtectedString.java b/app/src/main/java/com/keepassdroid/database/security/ProtectedString.java index 6e2aff9a0..0b1015b46 100644 --- a/app/src/main/java/com/keepassdroid/database/security/ProtectedString.java +++ b/app/src/main/java/com/keepassdroid/database/security/ProtectedString.java @@ -19,7 +19,9 @@ */ package com.keepassdroid.database.security; -public class ProtectedString { +import java.io.Serializable; + +public class ProtectedString implements Serializable { private String string; private boolean protect; diff --git a/app/src/main/java/com/keepassdroid/FilePickerStylishActivity.java b/app/src/main/java/com/keepassdroid/fileselect/FilePickerStylishActivity.java similarity index 98% rename from app/src/main/java/com/keepassdroid/FilePickerStylishActivity.java rename to app/src/main/java/com/keepassdroid/fileselect/FilePickerStylishActivity.java index 61952740e..a40cb82db 100644 --- a/app/src/main/java/com/keepassdroid/FilePickerStylishActivity.java +++ b/app/src/main/java/com/keepassdroid/fileselect/FilePickerStylishActivity.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.fileselect; import android.content.Context; import android.os.Bundle; diff --git a/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java b/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java index 29e38b330..35e538fe2 100644 --- a/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java +++ b/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java @@ -21,18 +21,15 @@ package com.keepassdroid.fileselect; import android.Manifest; import android.app.Activity; -import android.content.ActivityNotFoundException; -import android.content.ContentResolver; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; -import android.content.pm.PackageManager; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.preference.PreferenceManager; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; +import android.support.annotation.NonNull; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; @@ -43,27 +40,23 @@ import android.view.View; import android.widget.EditText; import android.widget.Toast; -import com.keepassdroid.AssignMasterKeyDialog; -import com.keepassdroid.CreateFileDialog; -import com.keepassdroid.GroupActivity; -import com.keepassdroid.PasswordActivity; -import com.keepassdroid.ProgressTask; +import com.keepassdroid.activities.GroupActivity; import com.keepassdroid.app.App; import com.keepassdroid.autofill.AutofillHelper; -import com.keepassdroid.compat.ContentResolverCompat; -import com.keepassdroid.compat.StorageAF; import com.keepassdroid.database.edit.CreateDB; import com.keepassdroid.database.edit.FileOnFinish; import com.keepassdroid.database.exception.ContentFileNotFoundException; -import com.keepassdroid.intents.Intents; +import com.keepassdroid.fragments.AssignMasterKeyDialogFragment; +import com.keepassdroid.fragments.CreateFileDialogFragment; +import com.keepassdroid.password.PasswordActivity; import com.keepassdroid.stylish.StylishActivity; +import com.keepassdroid.tasks.ProgressTask; import com.keepassdroid.utils.EmptyUtils; -import com.keepassdroid.utils.Interaction; import com.keepassdroid.utils.MenuUtil; import com.keepassdroid.utils.UriUtil; -import com.keepassdroid.utils.Util; import com.keepassdroid.view.AssignPasswordHelper; import com.keepassdroid.view.FileNameView; +import com.keepassdroid.view.KeyFileHelper; import com.kunzisoft.keepass.R; import java.io.File; @@ -71,22 +64,25 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.net.URLDecoder; +import permissions.dispatcher.NeedsPermission; +import permissions.dispatcher.OnNeverAskAgain; +import permissions.dispatcher.OnPermissionDenied; +import permissions.dispatcher.OnShowRationale; +import permissions.dispatcher.PermissionRequest; +import permissions.dispatcher.RuntimePermissions; + +@RuntimePermissions public class FileSelectActivity extends StylishActivity implements - CreateFileDialog.DefinePathDialogListener , - AssignMasterKeyDialog.AssignPasswordDialogListener, + CreateFileDialogFragment.DefinePathDialogListener , + AssignMasterKeyDialogFragment.AssignPasswordDialogListener, + FileSelectAdapter.FileItemOpenListener, FileSelectAdapter.FileSelectClearListener, FileSelectAdapter.FileInformationShowListener { private static final String TAG = "FileSelectActivity"; - private static final int MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE = 111; - private RecyclerView mListFiles; - private FileSelectAdapter mAdapter; + private FileSelectAdapter mAdapter; private View fileListTitle; - - public static final int FILE_BROWSE = 1; - public static final int GET_CONTENT = 2; - public static final int OPEN_DOC = 3; private RecentFileHistory fileHistory; @@ -94,20 +90,23 @@ public class FileSelectActivity extends StylishActivity implements private boolean consultationMode = false; private EditText openFileNameView; + private FileNameView fileNameView; private AssignPasswordHelper assignPasswordHelper; private Uri databaseUri; - public static void launch(Activity act) { - launch(act, null); - } + private KeyFileHelper keyFileHelper; - public static void launch(Activity act, Bundle extra) { - Intent intent = new Intent(act, FileSelectActivity.class); - if (extra != null) - intent.putExtras(extra); - act.startActivityForResult(intent, 0); - } + public static void launch(Activity activity) { + launch(activity, null); + } + + public static void launch(Activity activity, Bundle extras) { + Intent intent = new Intent(activity, FileSelectActivity.class); + if (extras != null) + intent.putExtras(extras); + activity.startActivity(intent); + } @Override protected void onCreate(Bundle savedInstanceState) { @@ -128,7 +127,17 @@ public class FileSelectActivity extends StylishActivity implements toolbar.setTitle(getString(R.string.app_name)); setSupportActionBar(toolbar); - mListFiles = (RecyclerView) findViewById(R.id.file_list); + openFileNameView = (EditText) findViewById(R.id.file_filename); + fileNameView = (FileNameView) findViewById(R.id.file_select); + + // Set the initial value of the filename + String 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.setText(defaultPath); + + RecyclerView mListFiles = (RecyclerView) findViewById(R.id.file_list); mListFiles.setLayoutManager(new LinearLayoutManager(this)); // Open button @@ -136,10 +145,9 @@ public class FileSelectActivity extends StylishActivity implements openButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - String fileName = Util.getEditText(FileSelectActivity.this, - R.id.file_filename); + String fileName = openFileNameView.getText().toString(); try { - PasswordActivity.Launch(FileSelectActivity.this, + PasswordActivity.launch(FileSelectActivity.this, fileName, getIntent().getExtras()); } @@ -155,76 +163,30 @@ public class FileSelectActivity extends StylishActivity implements }); // Create button - View createButton = findViewById(R.id.create_database); - if (!consultationMode) { - createButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - CreateFileDialog createFileDialog = new CreateFileDialog(); - createFileDialog.show(getSupportFragmentManager(), "createFileDialog"); - } - }); - } else { - createButton.setVisibility(View.GONE); - } - - View browseButton = findViewById(R.id.browse_button); - browseButton.setOnClickListener(new View.OnClickListener() { - + View createButton = findViewById(R.id.create_database); + createButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - if (StorageAF.useStorageFramework(FileSelectActivity.this)) { - Intent i = new Intent(StorageAF.ACTION_OPEN_DOCUMENT); - i.addCategory(Intent.CATEGORY_OPENABLE); - i.setType("*/*"); - i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION| - Intent.FLAG_GRANT_WRITE_URI_PERMISSION| - Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); - startActivityForResult(i, OPEN_DOC); - } - else { - Intent i; - i = new Intent(Intent.ACTION_GET_CONTENT); - i.addCategory(Intent.CATEGORY_OPENABLE); - i.setType("*/*"); - - try { - startActivityForResult(i, GET_CONTENT); - } catch (ActivityNotFoundException e) { - lookForOpenIntentsFilePicker(); - } catch (SecurityException e) { - lookForOpenIntentsFilePicker(); - } - } - } - - private void lookForOpenIntentsFilePicker() { - if (Interaction.isIntentAvailable(FileSelectActivity.this, Intents.OPEN_INTENTS_FILE_BROWSE)) { - Intent i = new Intent(Intents.OPEN_INTENTS_FILE_BROWSE); - i.setData(Uri.parse("file://" + Util.getEditText(FileSelectActivity.this, R.id.file_filename))); - try { - startActivityForResult(i, FILE_BROWSE); - } catch (ActivityNotFoundException e) { - showBrowserDialog(); - } - } else { - showBrowserDialog(); - } - } - - private void showBrowserDialog() { - BrowserDialog diag = new BrowserDialog(FileSelectActivity.this); - diag.show(); + FileSelectActivityPermissionsDispatcher + .openCreateFileDialogFragmentWithPermissionCheck(FileSelectActivity.this); } }); - // Set the initial value of the filename - openFileNameView = (EditText) findViewById(R.id.file_filename); - String 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.setText(defaultPath); + keyFileHelper = new KeyFileHelper(this); + View browseButton = findViewById(R.id.browse_button); + browseButton.setOnClickListener(keyFileHelper.getOpenFileOnClickViewListener( + new KeyFileHelper.ClickDataUriCallback() { + @Override + public Uri onRequestIntentFilePicker() { + return Uri.parse("file://" + openFileNameView.getText().toString()); + } + })); - fillData(); + // 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 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); @@ -242,7 +204,7 @@ public class FileSelectActivity extends StylishActivity implements if (db.exists()) { try { - PasswordActivity.Launch(FileSelectActivity.this, + PasswordActivity.launch(FileSelectActivity.this, path, getIntent().getExtras()); } catch (Exception e) { @@ -252,7 +214,7 @@ public class FileSelectActivity extends StylishActivity implements } else { try { - PasswordActivity.Launch(FileSelectActivity.this, + PasswordActivity.launch(FileSelectActivity.this, dbUri.toString(), getIntent().getExtras()); } catch (Exception e) { @@ -262,6 +224,36 @@ public class FileSelectActivity extends StylishActivity implements } } + @Override + protected void onResume() { + super.onResume(); + + // Check to see if we need to change modes + if ( fileHistory.hasRecentFiles() != recentMode ) { + // Restart the activity + Intent intent = getIntent(); + startActivity(intent); + finish(); + } + + fileNameView.updateExternalStorageWarning(); + updateTitleFileListView(); + mAdapter.notifyDataSetChanged(); + } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + // NOTE: delegate the permission handling to generated method + FileSelectActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults); + } + + @NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) + public void openCreateFileDialogFragment() { + CreateFileDialogFragment createFileDialogFragment = new CreateFileDialogFragment(); + createFileDialogFragment.show(getSupportFragmentManager(), "createFileDialogFragment"); + } + private void updateTitleFileListView() { if(mAdapter.getItemCount() == 0) fileListTitle.setVisibility(View.INVISIBLE); @@ -333,8 +325,8 @@ public class FileSelectActivity extends StylishActivity implements public boolean onDefinePathDialogPositiveClick(Uri pathFile) { databaseUri = pathFile; if(createDatabaseFile(pathFile)) { - AssignMasterKeyDialog assignMasterKeyDialog = new AssignMasterKeyDialog(); - assignMasterKeyDialog.show(getSupportFragmentManager(), "passwordDialog"); + AssignMasterKeyDialogFragment assignMasterKeyDialogFragment = new AssignMasterKeyDialogFragment(); + assignMasterKeyDialogFragment.show(getSupportFragmentManager(), "passwordDialog"); return true; } else return false; @@ -379,7 +371,7 @@ public class FileSelectActivity extends StylishActivity implements } - private class AssignPasswordOnFinish extends FileOnFinish { + private class AssignPasswordOnFinish extends FileOnFinish { AssignPasswordOnFinish(FileOnFinish fileOnFinish) { super(fileOnFinish); @@ -413,36 +405,26 @@ public class FileSelectActivity extends StylishActivity implements } } - private void fillData() { - mAdapter = new FileSelectAdapter(FileSelectActivity.this, fileHistory.getDbList()); - mAdapter.setOnItemClickListener( - new View.OnClickListener() { - public void onClick(View view) { - int itemPosition = mListFiles.getChildLayoutPosition(view); - new OpenFileHistoryAsyncTask(new OpenFileHistoryAsyncTask.AfterOpenFileHistoryListener() { - @Override - public void afterOpenFile(String fileName, String keyFile) { - try { - PasswordActivity.Launch(FileSelectActivity.this, - fileName, keyFile, getIntent().getExtras()); - } catch (ContentFileNotFoundException e) { - Toast.makeText(FileSelectActivity.this, - R.string.file_not_found_content, Toast.LENGTH_LONG) - .show(); - } catch (FileNotFoundException e) { - Toast.makeText(FileSelectActivity.this, - R.string.file_not_found, Toast.LENGTH_LONG) - .show(); - } - updateTitleFileListView(); - } - }, fileHistory).execute(itemPosition); - } - } - ); - mAdapter.setFileSelectClearListener(this); - mAdapter.setFileInformationShowListener(this); - mListFiles.setAdapter(mAdapter); + @Override + public void onFileItemOpenListener(int itemPosition) { + new OpenFileHistoryAsyncTask(new OpenFileHistoryAsyncTask.AfterOpenFileHistoryListener() { + @Override + public void afterOpenFile(String fileName, String keyFile) { + try { + PasswordActivity.launch(FileSelectActivity.this, + fileName, keyFile, getIntent().getExtras()); + } catch (ContentFileNotFoundException e) { + Toast.makeText(FileSelectActivity.this, + R.string.file_not_found_content, Toast.LENGTH_LONG) + .show(); + } catch (FileNotFoundException e) { + Toast.makeText(FileSelectActivity.this, + R.string.file_not_found, Toast.LENGTH_LONG) + .show(); + } + updateTitleFileListView(); + } + }, fileHistory).execute(itemPosition); } @Override @@ -471,121 +453,46 @@ public class FileSelectActivity extends StylishActivity implements protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - fillData(); - - String filename = null; - if (requestCode == FILE_BROWSE && resultCode == RESULT_OK) { - filename = data.getDataString(); - if (filename != null) { - if (filename.startsWith("file://")) { - filename = filename.substring(7); - } - - filename = URLDecoder.decode(filename); - } - - } - else if ((requestCode == GET_CONTENT || requestCode == OPEN_DOC) && resultCode == RESULT_OK) { - if (data != null) { - Uri uri = data.getData(); - if (uri != null) { - if (StorageAF.useStorageFramework(this)) { - try { - // try to persist read and write permissions - ContentResolver resolver = getContentResolver(); - ContentResolverCompat.takePersistableUriPermission(resolver, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); - ContentResolverCompat.takePersistableUriPermission(resolver, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION); - } catch (Exception e) { - // nop - } - } - if (requestCode == GET_CONTENT) { - uri = UriUtil.translate(this, uri); - } - filename = uri.toString(); - } - } - } - - if (filename != null) { - openFileNameView.setText(filename); - } + keyFileHelper.onActivityResultCallback(requestCode, resultCode, data, + new KeyFileHelper.KeyFileCallback() { + @Override + public void onKeyFileResultCallback(Uri uri) { + if (uri != null) { + String filename = uri.toString(); + openFileNameView.setText(filename); + } + } + }); } - @Override - protected void onResume() { - super.onResume(); + @OnShowRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE) + void showRationaleForExternalStorage(final PermissionRequest request) { + new AlertDialog.Builder(this) + .setMessage(R.string.permission_external_storage_rationale_write_database) + .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + request.proceed(); + } + }) + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + request.cancel(); + } + }) + .show(); + } - // check for storage permission - checkStoragePermission(); - - // Check to see if we need to change modes - if ( fileHistory.hasRecentFiles() != recentMode ) { - // Restart the activity - Intent intent = getIntent(); - startActivity(intent); - finish(); - } - - FileNameView fnv = (FileNameView) findViewById(R.id.file_select); - fnv.updateExternalStorageWarning(); + @OnPermissionDenied(Manifest.permission.WRITE_EXTERNAL_STORAGE) + void showDeniedForExternalStorage() { + Toast.makeText(this, R.string.permission_external_storage_denied, Toast.LENGTH_SHORT).show(); + } - updateTitleFileListView(); - } - - private void checkStoragePermission() { - // Here, thisActivity is the current activity - if (ContextCompat.checkSelfPermission(FileSelectActivity.this, - Manifest.permission.WRITE_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) { - - // Should we show an explanation? - //if (ActivityCompat.shouldShowRequestPermissionRationale(FileSelectActivity.this, - // Manifest.permission.WRITE_EXTERNAL_STORAGE)) { - - // Show an explanation to the user *asynchronously* -- don't block - // this thread waiting for the user's response! After the user - // sees the explanation, try again to request the permission. - - //} else { - - // No explanation needed, we can request the permission. - - ActivityCompat.requestPermissions(FileSelectActivity.this, - new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, - MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE); - - // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an - // app-defined int constant. The callback method gets the - // result of the request. - //} - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, - String permissions[], int[] grantResults) { - switch (requestCode) { - case MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE: { - // If request is cancelled, the result arrays are empty. - if (grantResults.length > 0 - && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - - // permission was granted, yay! Do the - // contacts-related task you need to do. - - } else { - - // permission denied, boo! Disable the - // functionality that depends on this permission. - } - return; - } - - // other 'case' lines to check for other - // permissions this app might request - } - } + @OnNeverAskAgain(Manifest.permission.WRITE_EXTERNAL_STORAGE) + void showNeverAskForExternalStorage() { + Toast.makeText(this, R.string.permission_external_storage_never_ask, Toast.LENGTH_SHORT).show(); + } @Override public boolean onCreateOptionsMenu(Menu menu) { diff --git a/app/src/main/java/com/keepassdroid/fileselect/FileSelectAdapter.java b/app/src/main/java/com/keepassdroid/fileselect/FileSelectAdapter.java index a9a2ebc6d..12e30af90 100644 --- a/app/src/main/java/com/keepassdroid/fileselect/FileSelectAdapter.java +++ b/app/src/main/java/com/keepassdroid/fileselect/FileSelectAdapter.java @@ -44,7 +44,7 @@ public class FileSelectAdapter extends RecyclerView.Adapter listFiles; - private View.OnClickListener mOnClickListener; + private FileItemOpenListener fileItemOpenListener; private FileSelectClearListener fileSelectClearListener; private FileInformationShowListener fileInformationShowListener; @@ -52,7 +52,7 @@ public class FileSelectAdapter extends RecyclerView.Adapter listFiles) { - inflater = LayoutInflater.from(context); + this.inflater = LayoutInflater.from(context); this.context = context; this.listFiles = listFiles; @@ -65,27 +65,30 @@ public class FileSelectAdapter extends RecyclerView.Adapter= BuildCompat.VERSION_CODE_M - && fingerprintManager != null + return fingerprintManager != null && fingerprintManager.isHardwareDetected(); } @@ -141,7 +137,6 @@ public class FingerPrintHelper { return isFingerprintInit; } - @RequiresApi(api = Build.VERSION_CODES.M) public void initEncryptData() { if (!isFingerprintInitialized()) { return; @@ -152,7 +147,6 @@ public class FingerPrintHelper { final SecretKey key = (SecretKey) keyStore.getKey(FINGERPRINT_KEYSTORE_KEY, null); cipher.init(Cipher.ENCRYPT_MODE, key); - stopListening(); startListening(); } catch (final UnrecoverableKeyException unrecoverableKeyException) { deleteEntryKey(); @@ -182,7 +176,6 @@ public class FingerPrintHelper { } } - @RequiresApi(api = Build.VERSION_CODES.M) public void initDecryptData(final String ivSpecValue) { if (!isFingerprintInitialized()) { return; @@ -197,9 +190,7 @@ public class FingerPrintHelper { final IvParameterSpec spec = new IvParameterSpec(iv); cipher.init(Cipher.DECRYPT_MODE, key, spec); - stopListening(); startListening(); - } catch (final KeyPermanentlyInvalidatedException invalidKeyException) { fingerPrintCallback.onInvalidKeyException(invalidKeyException); } catch (final UnrecoverableKeyException unrecoverableKeyException) { @@ -269,8 +260,10 @@ public class FingerPrintHelper { } catch (KeyStoreException | CertificateException | NoSuchAlgorithmException - | IOException e) { - fingerPrintCallback.onFingerPrintException(e); + | IOException + | NullPointerException e) { + if (fingerPrintCallback != null) + fingerPrintCallback.onFingerPrintException(e); } } @@ -324,4 +317,8 @@ public class FingerPrintHelper { void handleDecryptedResult(String value); } + public enum Mode { + NOT_CONFIGURED_MODE, STORE_MODE, OPEN_MODE + } + } \ No newline at end of file diff --git a/app/src/main/java/com/keepassdroid/AssignMasterKeyDialog.java b/app/src/main/java/com/keepassdroid/fragments/AssignMasterKeyDialogFragment.java similarity index 97% rename from app/src/main/java/com/keepassdroid/AssignMasterKeyDialog.java rename to app/src/main/java/com/keepassdroid/fragments/AssignMasterKeyDialogFragment.java index ff2dcaf3f..3dc236e6d 100644 --- a/app/src/main/java/com/keepassdroid/AssignMasterKeyDialog.java +++ b/app/src/main/java/com/keepassdroid/fragments/AssignMasterKeyDialogFragment.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.fragments; import android.app.Dialog; import android.content.Context; @@ -42,7 +42,7 @@ import com.keepassdroid.utils.UriUtil; import com.keepassdroid.view.KeyFileHelper; import com.kunzisoft.keepass.R; -public class AssignMasterKeyDialog extends DialogFragment { +public class AssignMasterKeyDialogFragment extends DialogFragment { private String masterPassword; private Uri mKeyfile; @@ -226,7 +226,7 @@ public class AssignMasterKeyDialog extends DialogFragment { mListener.onAssignKeyDialogPositiveClick( passwordCheckBox.isChecked(), masterPassword, keyfileCheckBox.isChecked(), mKeyfile); - AssignMasterKeyDialog.this.dismiss(); + AssignMasterKeyDialogFragment.this.dismiss(); } } }) @@ -244,7 +244,7 @@ public class AssignMasterKeyDialog extends DialogFragment { mListener.onAssignKeyDialogPositiveClick( passwordCheckBox.isChecked(), masterPassword, keyfileCheckBox.isChecked(), mKeyfile); - AssignMasterKeyDialog.this.dismiss(); + AssignMasterKeyDialogFragment.this.dismiss(); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { diff --git a/app/src/main/java/com/keepassdroid/CreateFileDialog.java b/app/src/main/java/com/keepassdroid/fragments/CreateFileDialogFragment.java similarity index 95% rename from app/src/main/java/com/keepassdroid/CreateFileDialog.java rename to app/src/main/java/com/keepassdroid/fragments/CreateFileDialogFragment.java index 0f941d11a..e07181b28 100644 --- a/app/src/main/java/com/keepassdroid/CreateFileDialog.java +++ b/app/src/main/java/com/keepassdroid/fragments/CreateFileDialogFragment.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.fragments; import android.app.Activity; import android.app.Dialog; @@ -38,6 +38,7 @@ import android.widget.Button; import android.widget.EditText; import android.widget.Spinner; +import com.keepassdroid.fileselect.FilePickerStylishActivity; import com.keepassdroid.utils.UriUtil; import com.kunzisoft.keepass.R; import com.nononsenseapps.filepicker.FilePickerActivity; @@ -45,7 +46,7 @@ import com.nononsenseapps.filepicker.Utils; import java.io.File; -public class CreateFileDialog extends DialogFragment implements AdapterView.OnItemSelectedListener{ +public class CreateFileDialogFragment extends DialogFragment implements AdapterView.OnItemSelectedListener{ private final int FILE_CODE = 3853; @@ -134,7 +135,7 @@ public class CreateFileDialog extends DialogFragment implements AdapterView.OnIt @Override public void onClick(final View v) { if(mListener.onDefinePathDialogPositiveClick(buildPath())) - CreateFileDialog.this.dismiss(); + CreateFileDialogFragment.this.dismiss(); } }); Button negativeButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_NEGATIVE); @@ -142,7 +143,7 @@ public class CreateFileDialog extends DialogFragment implements AdapterView.OnIt @Override public void onClick(final View v) { if(mListener.onDefinePathDialogNegativeClick(buildPath())) - CreateFileDialog.this.dismiss(); + CreateFileDialogFragment.this.dismiss(); } }); } diff --git a/app/src/main/java/com/keepassdroid/GeneratePasswordFragment.java b/app/src/main/java/com/keepassdroid/fragments/GeneratePasswordDialogFragment.java similarity index 98% rename from app/src/main/java/com/keepassdroid/GeneratePasswordFragment.java rename to app/src/main/java/com/keepassdroid/fragments/GeneratePasswordDialogFragment.java index 5890ed442..f47a0f572 100644 --- a/app/src/main/java/com/keepassdroid/GeneratePasswordFragment.java +++ b/app/src/main/java/com/keepassdroid/fragments/GeneratePasswordDialogFragment.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.fragments; import android.app.Dialog; import android.content.Context; @@ -41,7 +41,7 @@ import com.kunzisoft.keepass.R; import java.util.Set; -public class GeneratePasswordFragment extends DialogFragment { +public class GeneratePasswordDialogFragment extends DialogFragment { public static final String KEY_PASSWORD_ID = "KEY_PASSWORD_ID"; diff --git a/app/src/main/java/com/keepassdroid/GroupEditFragment.java b/app/src/main/java/com/keepassdroid/fragments/GroupEditDialogFragment.java similarity index 61% rename from app/src/main/java/com/keepassdroid/GroupEditFragment.java rename to app/src/main/java/com/keepassdroid/fragments/GroupEditDialogFragment.java index abf928a15..639288cb8 100644 --- a/app/src/main/java/com/keepassdroid/GroupEditFragment.java +++ b/app/src/main/java/com/keepassdroid/fragments/GroupEditDialogFragment.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.fragments; import android.app.Dialog; import android.content.Context; @@ -32,56 +32,78 @@ import android.widget.ImageButton; import android.widget.TextView; import android.widget.Toast; -import com.kunzisoft.keepass.R; +import com.keepassdroid.database.PwNode; import com.keepassdroid.icons.Icons; +import com.kunzisoft.keepass.R; -public class GroupEditFragment extends DialogFragment - implements IconPickerFragment.IconPickerListener { +public class GroupEditDialogFragment extends DialogFragment + implements IconPickerDialogFragment.IconPickerListener { + + public static final String TAG_CREATE_GROUP = "TAG_CREATE_GROUP"; public static final String KEY_NAME = "name"; public static final String KEY_ICON_ID = "icon_id"; - private CreateGroupListener createGroupListener; + private EditGroupListener editGroupListener; + private TextView nameField; + private ImageButton iconButton; private int mSelectedIconID; private View root; + public static GroupEditDialogFragment build(PwNode group) { + Bundle bundle = new Bundle(); + bundle.putString(KEY_NAME, group.getDisplayTitle()); + // TODO Change + bundle.putInt(KEY_ICON_ID, group.getIcon().hashCode()); + GroupEditDialogFragment fragment = new GroupEditDialogFragment(); + fragment.setArguments(bundle); + return fragment; + } + @Override public void onAttach(Context context) { super.onAttach(context); // Verify that the host activity implements the callback interface try { // Instantiate the NoticeDialogListener so we can send events to the host - createGroupListener = (CreateGroupListener) context; - createGroupListener = (CreateGroupListener) context; + editGroupListener = (EditGroupListener) context; } catch (ClassCastException e) { // The activity doesn't implement the interface, throw exception throw new ClassCastException(context.toString() - + " must implement " + GroupEditFragment.class.getName()); + + " must implement " + GroupEditDialogFragment.class.getName()); } } @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - LayoutInflater inflater = getActivity().getLayoutInflater(); + LayoutInflater inflater = getActivity().getLayoutInflater(); root = inflater.inflate(R.layout.group_edit, null); + nameField = (TextView) root.findViewById(R.id.group_name); + iconButton = (ImageButton) root.findViewById(R.id.icon_button); + + if (getArguments() != null + && getArguments().containsKey(KEY_NAME) + && getArguments().containsKey(KEY_ICON_ID)) { + nameField.setText(getArguments().getString(KEY_NAME)); + populateIcon(getArguments().getInt(KEY_ICON_ID)); + } + + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(root) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { - TextView nameField = (TextView) root.findViewById(R.id.group_name); String name = nameField.getText().toString(); - if ( name.length() > 0 ) { Bundle bundle = new Bundle(); bundle.putString(KEY_NAME, name); bundle.putInt(KEY_ICON_ID, mSelectedIconID); - createGroupListener.approveCreateGroup(bundle); + editGroupListener.approveEditGroup(bundle); - GroupEditFragment.this.getDialog().cancel(); + GroupEditDialogFragment.this.getDialog().cancel(); } else { Toast.makeText(getContext(), R.string.error_no_name, Toast.LENGTH_LONG).show(); @@ -91,32 +113,35 @@ public class GroupEditFragment extends DialogFragment .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Bundle bundle = new Bundle(); - createGroupListener.cancelCreateGroup(bundle); + editGroupListener.cancelEditGroup(bundle); - GroupEditFragment.this.getDialog().cancel(); + GroupEditDialogFragment.this.getDialog().cancel(); } }); final ImageButton iconButton = (ImageButton) root.findViewById(R.id.icon_button); iconButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - IconPickerFragment iconPickerFragment = new IconPickerFragment(); - iconPickerFragment.show(getFragmentManager(), "IconPickerFragment"); + IconPickerDialogFragment iconPickerDialogFragment = new IconPickerDialogFragment(); + iconPickerDialogFragment.show(getFragmentManager(), "IconPickerDialogFragment"); } }); return builder.create(); } - @Override - public void iconPicked(Bundle bundle) { - mSelectedIconID = bundle.getInt(IconPickerFragment.KEY_ICON_ID); - ImageButton currIconButton = (ImageButton) root.findViewById(R.id.icon_button); - currIconButton.setImageResource(Icons.iconToResId(mSelectedIconID)); + private void populateIcon(int iconId) { + iconButton.setImageResource(Icons.iconToResId(iconId)); } - public interface CreateGroupListener { - void approveCreateGroup(Bundle bundle); - void cancelCreateGroup(Bundle bundle); + @Override + public void iconPicked(Bundle bundle) { + mSelectedIconID = bundle.getInt(IconPickerDialogFragment.KEY_ICON_ID); + populateIcon(mSelectedIconID); + } + + public interface EditGroupListener { + void approveEditGroup(Bundle bundle); + void cancelEditGroup(Bundle bundle); } } diff --git a/app/src/main/java/com/keepassdroid/IconPickerFragment.java b/app/src/main/java/com/keepassdroid/fragments/IconPickerDialogFragment.java similarity index 93% rename from app/src/main/java/com/keepassdroid/IconPickerFragment.java rename to app/src/main/java/com/keepassdroid/fragments/IconPickerDialogFragment.java index bd6e8c6e2..582a39901 100644 --- a/app/src/main/java/com/keepassdroid/IconPickerFragment.java +++ b/app/src/main/java/com/keepassdroid/fragments/IconPickerDialogFragment.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.fragments; import android.app.Dialog; import android.content.Context; @@ -41,13 +41,13 @@ import com.keepassdroid.icons.Icons; import com.keepassdroid.stylish.StylishActivity; -public class IconPickerFragment extends DialogFragment { +public class IconPickerDialogFragment extends DialogFragment { public static final String KEY_ICON_ID = "icon_id"; private IconPickerListener iconPickerListener; - public static void Launch(StylishActivity activity) { + public static void launch(StylishActivity activity) { // Create an instance of the dialog fragment and show it - IconPickerFragment dialog = new IconPickerFragment(); + IconPickerDialogFragment dialog = new IconPickerDialogFragment(); dialog.show(activity.getSupportFragmentManager(), "NoticeDialogFragment"); } @@ -90,7 +90,7 @@ public class IconPickerFragment extends DialogFragment { builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { - IconPickerFragment.this.getDialog().cancel(); + IconPickerDialogFragment.this.getDialog().cancel(); } }); diff --git a/app/src/main/java/com/keepassdroid/fragments/SortDialogFragment.java b/app/src/main/java/com/keepassdroid/fragments/SortDialogFragment.java new file mode 100644 index 000000000..cdade3a23 --- /dev/null +++ b/app/src/main/java/com/keepassdroid/fragments/SortDialogFragment.java @@ -0,0 +1,235 @@ +/* + * Copyright 2018 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.fragments; + +import android.app.Dialog; +import android.content.Context; +import android.content.DialogInterface; +import android.os.Bundle; +import android.support.annotation.IdRes; +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.CompoundButton; +import android.widget.RadioGroup; + +import com.keepassdroid.database.SortNodeEnum; +import com.kunzisoft.keepass.R; + +public class SortDialogFragment extends DialogFragment { + + private static final String SORT_NODE_ENUM_BUNDLE_KEY = "SORT_NODE_ENUM_BUNDLE_KEY"; + private static final String SORT_ASCENDING_BUNDLE_KEY = "SORT_ASCENDING_BUNDLE_KEY"; + private static final String SORT_GROUPS_BEFORE_BUNDLE_KEY = "SORT_GROUPS_BEFORE_BUNDLE_KEY"; + private static final String SORT_RECYCLE_BIN_BOTTOM_BUNDLE_KEY = "SORT_RECYCLE_BIN_BOTTOM_BUNDLE_KEY"; + + private SortSelectionListener mListener; + + private SortNodeEnum sortNodeEnum; + private @IdRes + int mCheckedId; + private boolean mGroupsBefore; + private boolean mAscending; + private boolean mRecycleBinBottom; + + private static Bundle buildBundle(SortNodeEnum sortNodeEnum, + boolean ascending, + boolean groupsBefore) { + Bundle bundle = new Bundle(); + bundle.putString(SORT_NODE_ENUM_BUNDLE_KEY, sortNodeEnum.name()); + bundle.putBoolean(SORT_ASCENDING_BUNDLE_KEY, ascending); + bundle.putBoolean(SORT_GROUPS_BEFORE_BUNDLE_KEY, groupsBefore); + return bundle; + } + + public static SortDialogFragment getInstance(SortNodeEnum sortNodeEnum, + boolean ascending, + boolean groupsBefore) { + Bundle bundle = buildBundle(sortNodeEnum, ascending, groupsBefore); + SortDialogFragment fragment = new SortDialogFragment(); + fragment.setArguments(bundle); + return fragment; + } + + public static SortDialogFragment getInstance(SortNodeEnum sortNodeEnum, + boolean ascending, + boolean groupsBefore, + boolean recycleBinBottom) { + Bundle bundle = buildBundle(sortNodeEnum, ascending, groupsBefore); + bundle.putBoolean(SORT_RECYCLE_BIN_BOTTOM_BUNDLE_KEY, recycleBinBottom); + SortDialogFragment fragment = new SortDialogFragment(); + fragment.setArguments(bundle); + return fragment; + } + + @Override + public void onAttach(Context context) { + super.onAttach(context); + try { + mListener = (SortSelectionListener) context; + } catch (ClassCastException e) { + throw new ClassCastException(context.toString() + + " must implement " + SortSelectionListener.class.getName()); + } + } + + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + LayoutInflater inflater = getActivity().getLayoutInflater(); + + sortNodeEnum = SortNodeEnum.TITLE; + mAscending = true; + mGroupsBefore = true; + boolean recycleBinAllowed = false; + mRecycleBinBottom = true; + + if (getArguments() != null) { + if (getArguments().containsKey(SORT_NODE_ENUM_BUNDLE_KEY)) + sortNodeEnum = SortNodeEnum.valueOf(getArguments().getString(SORT_NODE_ENUM_BUNDLE_KEY)); + if (getArguments().containsKey(SORT_ASCENDING_BUNDLE_KEY)) + mAscending = getArguments().getBoolean(SORT_ASCENDING_BUNDLE_KEY); + if (getArguments().containsKey(SORT_GROUPS_BEFORE_BUNDLE_KEY)) + mGroupsBefore = getArguments().getBoolean(SORT_GROUPS_BEFORE_BUNDLE_KEY); + if (getArguments().containsKey(SORT_RECYCLE_BIN_BOTTOM_BUNDLE_KEY)) { + recycleBinAllowed = true; + mRecycleBinBottom = getArguments().getBoolean(SORT_RECYCLE_BIN_BOTTOM_BUNDLE_KEY); + } + } + + mCheckedId = retrieveViewFromEnum(sortNodeEnum); + + View rootView = inflater.inflate(R.layout.sort_selection, null); + builder.setTitle(R.string.sort_menu); + builder.setView(rootView) + // Add action buttons + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + mListener.onSortSelected(sortNodeEnum, mAscending, mGroupsBefore, mRecycleBinBottom); + } + }) + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) {} + }); + + CompoundButton ascendingView = (CompoundButton) rootView.findViewById(R.id.sort_selection_ascending); + // Check if is ascending or descending + ascendingView.setChecked(mAscending); + ascendingView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mAscending = isChecked; + } + }); + + CompoundButton groupsBeforeView = (CompoundButton) rootView.findViewById(R.id.sort_selection_groups_before); + // Check if groups before + groupsBeforeView.setChecked(mGroupsBefore); + groupsBeforeView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mGroupsBefore = isChecked; + } + }); + + CompoundButton recycleBinBottomView = (CompoundButton) rootView.findViewById(R.id.sort_selection_recycle_bin_bottom); + if (!recycleBinAllowed) { + recycleBinBottomView.setVisibility(View.GONE); + } else { + // Check if recycle bin at the bottom + recycleBinBottomView.setChecked(mRecycleBinBottom); + recycleBinBottomView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mRecycleBinBottom = isChecked; + } + }); + } + + RadioGroup sortSelectionRadioGroupView = (RadioGroup) rootView.findViewById(R.id.sort_selection_radio_group); + // Check value by default + sortSelectionRadioGroupView.check(mCheckedId); + sortSelectionRadioGroupView.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + sortNodeEnum = retrieveSortEnumFromViewId(checkedId); + } + }); + + return builder.create(); + } + + private @IdRes + int retrieveViewFromEnum(SortNodeEnum sortNodeEnum) { + switch (sortNodeEnum) { + case DB: + return R.id.sort_selection_db; + default: + case TITLE: + return R.id.sort_selection_title; + case USERNAME: + return R.id.sort_selection_username; + case CREATION_TIME: + return R.id.sort_selection_creation_time; + case LAST_MODIFY_TIME: + return R.id.sort_selection_last_modify_time; + case LAST_ACCESS_TIME: + return R.id.sort_selection_last_access_time; + } + } + + private SortNodeEnum retrieveSortEnumFromViewId(@IdRes int checkedId) { + SortNodeEnum sortNodeEnum; + // Change enum + switch (checkedId) { + case R.id.sort_selection_db: + sortNodeEnum = SortNodeEnum.DB; + break; + default: + case R.id.sort_selection_title: + sortNodeEnum = SortNodeEnum.TITLE; + break; + case R.id.sort_selection_username: + sortNodeEnum = SortNodeEnum.USERNAME; + break; + case R.id.sort_selection_creation_time: + sortNodeEnum = SortNodeEnum.CREATION_TIME; + break; + case R.id.sort_selection_last_modify_time: + sortNodeEnum = SortNodeEnum.LAST_MODIFY_TIME; + break; + case R.id.sort_selection_last_access_time: + sortNodeEnum = SortNodeEnum.LAST_ACCESS_TIME; + break; + } + return sortNodeEnum; + } + + public interface SortSelectionListener { + void onSortSelected(SortNodeEnum sortNodeEnum, + boolean ascending, + boolean groupsBefore, + boolean recycleBinBottom); + } +} diff --git a/app/src/main/java/com/keepassdroid/UnavailableFeatureDialog.java b/app/src/main/java/com/keepassdroid/fragments/UnavailableFeatureDialogFragment.java similarity index 82% rename from app/src/main/java/com/keepassdroid/UnavailableFeatureDialog.java rename to app/src/main/java/com/keepassdroid/fragments/UnavailableFeatureDialogFragment.java index 7bef4ceed..15dae90d0 100644 --- a/app/src/main/java/com/keepassdroid/UnavailableFeatureDialog.java +++ b/app/src/main/java/com/keepassdroid/fragments/UnavailableFeatureDialogFragment.java @@ -1,4 +1,4 @@ -package com.keepassdroid; +package com.keepassdroid.fragments; import android.app.Dialog; import android.content.DialogInterface; @@ -10,13 +10,13 @@ import android.support.v7.app.AlertDialog; import com.kunzisoft.keepass.R; -public class UnavailableFeatureDialog extends DialogFragment { +public class UnavailableFeatureDialogFragment extends DialogFragment { private static final String MIN_REQUIRED_VERSION_ARG = "MIN_REQUIRED_VERSION_ARG"; private int minVersionRequired = Build.VERSION_CODES.M; - public static UnavailableFeatureDialog getInstance(int minVersionRequired) { - UnavailableFeatureDialog fragment = new UnavailableFeatureDialog(); + public static UnavailableFeatureDialogFragment getInstance(int minVersionRequired) { + UnavailableFeatureDialogFragment fragment = new UnavailableFeatureDialogFragment(); Bundle args = new Bundle(); args.putInt(MIN_REQUIRED_VERSION_ARG, minVersionRequired); fragment.setArguments(args); @@ -32,7 +32,7 @@ public class UnavailableFeatureDialog extends DialogFragment { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); String message = getString(R.string.unavailable_feature_text).concat("\n"); - if(Build.VERSION.SDK_INT <= minVersionRequired) + if(Build.VERSION.SDK_INT < minVersionRequired) message = message.concat(getString(R.string.unavailable_feature_version, Build.VERSION.SDK_INT, minVersionRequired)); diff --git a/app/src/main/java/com/keepassdroid/icons/DrawableFactory.java b/app/src/main/java/com/keepassdroid/icons/DrawableFactory.java index 802e615e8..8b0a84569 100644 --- a/app/src/main/java/com/keepassdroid/icons/DrawableFactory.java +++ b/app/src/main/java/com/keepassdroid/icons/DrawableFactory.java @@ -53,10 +53,11 @@ public class DrawableFactory { public void assignDrawableTo(ImageView iv, Resources res, PwIcon icon) { Drawable draw = getIconDrawable(res, icon); - iv.setImageDrawable(draw); + if (iv != null && draw != null) + iv.setImageDrawable(draw); } - private Drawable getIconDrawable(Resources res, PwIcon icon) { + public Drawable getIconDrawable(Resources res, PwIcon icon) { if (icon instanceof PwIconStandard) { return getIconDrawable(res, (PwIconStandard) icon); } else { diff --git a/app/src/main/java/com/keepassdroid/PasswordActivity.java b/app/src/main/java/com/keepassdroid/password/PasswordActivity.java similarity index 71% rename from app/src/main/java/com/keepassdroid/PasswordActivity.java rename to app/src/main/java/com/keepassdroid/password/PasswordActivity.java index b11d7afdd..232661dd1 100644 --- a/app/src/main/java/com/keepassdroid/PasswordActivity.java +++ b/app/src/main/java/com/keepassdroid/password/PasswordActivity.java @@ -17,8 +17,9 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.password; +import android.Manifest; import android.app.Activity; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; @@ -30,12 +31,16 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; +import android.support.annotation.NonNull; import android.support.annotation.RequiresApi; import android.support.v4.hardware.fingerprint.FingerprintManagerCompat; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; +import android.util.Log; import android.view.Menu; +import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; @@ -45,16 +50,20 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import com.keepassdroid.activities.GroupActivity; +import com.keepassdroid.activities.LockingActivity; import com.keepassdroid.app.App; import com.keepassdroid.compat.BackupManagerCompat; import com.keepassdroid.compat.ClipDataCompat; import com.keepassdroid.compat.EditorCompat; +import com.keepassdroid.database.Database; import com.keepassdroid.database.edit.LoadDB; import com.keepassdroid.database.edit.OnFinish; import com.keepassdroid.dialog.PasswordEncodingDialogHelper; import com.keepassdroid.fingerprint.FingerPrintAnimatedVector; import com.keepassdroid.fingerprint.FingerPrintHelper; import com.keepassdroid.settings.PreferencesUtil; +import com.keepassdroid.tasks.ProgressTask; import com.keepassdroid.utils.EmptyUtils; import com.keepassdroid.utils.MenuUtil; import com.keepassdroid.utils.UriUtil; @@ -66,8 +75,18 @@ import com.kunzisoft.keepass.R; import java.io.File; import java.io.FileNotFoundException; -import javax.crypto.Cipher; +import permissions.dispatcher.NeedsPermission; +import permissions.dispatcher.OnNeverAskAgain; +import permissions.dispatcher.OnPermissionDenied; +import permissions.dispatcher.OnShowRationale; +import permissions.dispatcher.PermissionRequest; +import permissions.dispatcher.RuntimePermissions; +import static com.keepassdroid.fingerprint.FingerPrintHelper.Mode.NOT_CONFIGURED_MODE; +import static com.keepassdroid.fingerprint.FingerPrintHelper.Mode.OPEN_MODE; +import static com.keepassdroid.fingerprint.FingerPrintHelper.Mode.STORE_MODE; + +@RuntimePermissions public class PasswordActivity extends LockingActivity implements FingerPrintHelper.FingerPrintCallback, UriIntentInitTaskCallback { @@ -76,7 +95,6 @@ public class PasswordActivity extends LockingActivity private static final String KEY_LAUNCH_IMMEDIATELY = "launchImmediately"; private Uri mDbUri = null; - private Uri mKeyUri = null; SharedPreferences prefs; SharedPreferences prefsNoBackup; @@ -84,12 +102,11 @@ public class PasswordActivity extends LockingActivity private boolean fingerprintMustBeConfigured = true; private boolean mRememberKeyfile; - private int mode; + private FingerPrintHelper.Mode fingerPrintMode; private static final String PREF_KEY_VALUE_PREFIX = "valueFor_"; // key is a combination of db file name and this prefix private static final String PREF_KEY_IV_PREFIX = "ivFor_"; // key is a combination of db file name and this prefix private View fingerprintContainerView; - private View fingerprintImageView; private FingerPrintAnimatedVector fingerPrintAnimatedVector; private TextView fingerprintTextView; private TextView filenameView; @@ -100,22 +117,25 @@ public class PasswordActivity extends LockingActivity private CompoundButton checkboxKeyfileView; private CompoundButton checkboxDefaultDatabaseView; + private DefaultCheckChange defaultCheckChange; + private ValidateButtonViewClickListener validateButtonViewClickListener; + private KeyFileHelper keyFileHelper; - public static void Launch( + public static void launch( Activity act, String fileName) throws FileNotFoundException { - Launch(act, fileName, "", null); + launch(act, fileName, "", null); } - public static void Launch( + public static void launch( Activity act, String fileName, - Bundle extra) throws FileNotFoundException { - Launch(act, fileName, "", extra); + Bundle extras) throws FileNotFoundException { + launch(act, fileName, "", extras); } - public static void Launch( + public static void launch( Activity act, String fileName, String keyFile, @@ -198,9 +218,6 @@ public class PasswordActivity extends LockingActivity getSupportActionBar().setDisplayShowHomeEnabled(true); confirmButtonView = (Button) findViewById(R.id.pass_ok); - fingerprintContainerView = findViewById(R.id.fingerprint_container); - fingerprintImageView = findViewById(R.id.fingerprint_image); - fingerprintTextView = (TextView) findViewById(R.id.fingerprint_label); filenameView = (TextView) findViewById(R.id.filename); passwordView = (EditText) findViewById(R.id.password); keyFileView = (EditText) findViewById(R.id.pass_keyfile); @@ -237,80 +254,21 @@ public class PasswordActivity extends LockingActivity } }); - new UriIntentInitTask(this, mRememberKeyfile) - .execute(getIntent()); + defaultCheckChange = new DefaultCheckChange(); + validateButtonViewClickListener = new ValidateButtonViewClickListener(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + fingerprintContainerView = findViewById(R.id.fingerprint_container); + fingerprintTextView = (TextView) findViewById(R.id.fingerprint_label); + initForFingerprint(); fingerPrintAnimatedVector = new FingerPrintAnimatedVector(this, - (ImageView) fingerprintImageView); + (ImageView) findViewById(R.id.fingerprint_image)); } } - @Override - public void onPostInitTask(Uri dbUri, Uri keyFileUri, Integer errorStringId) { - - mDbUri = dbUri; - mKeyUri = keyFileUri; - - Intent intent = getIntent(); - String password = intent.getStringExtra(KEY_PASSWORD); - boolean launch_immediately = intent.getBooleanExtra(KEY_LAUNCH_IMMEDIATELY, false); - - if (errorStringId != null) { - Toast.makeText(PasswordActivity.this, errorStringId, Toast.LENGTH_LONG).show(); - finish(); - return; - } - - populateView(); - - confirmButtonView.setOnClickListener(new OkClickHandler()); - - if (password != null) { - passwordView.setText(password); - } - - checkboxDefaultDatabaseView.setOnCheckedChangeListener(new DefaultCheckChange()); - - retrieveSettings(); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - checkFingerprintAvailability(); - } - - if (launch_immediately) { - verifyCheckboxesAndLoadDatabase(password, mKeyUri); - } - } - - private void retrieveSettings() { - String defaultFilename = prefs.getString(KEY_DEFAULT_FILENAME, ""); - if (mDbUri!=null - && !EmptyUtils.isNullOrEmpty(mDbUri.getPath()) - && UriUtil.equalsDefaultfile(mDbUri, defaultFilename)) { - checkboxDefaultDatabaseView.setChecked(true); - } - } - - private void populateView() { - String db = (mDbUri == null) ? "" : mDbUri.toString(); - if (!db.isEmpty()) { - if (PreferencesUtil.isFullFilePathEnable(this)) - filenameView.setText(db); - else - filenameView.setText(new File(mDbUri.getPath()).getName()); // TODO Encapsulate - } - - String key = (mKeyUri == null) ? "" : mKeyUri.toString(); - if (!key.isEmpty() && mRememberKeyfile) { // Bug KeepassDX #18 - keyFileView.setText(key); - } - } @Override protected void onResume() { - super.onResume(); - // If the application was shutdown make sure to clear the password field, if it // was saved in the instance state if (App.isShutdown()) { @@ -320,14 +278,75 @@ public class PasswordActivity extends LockingActivity // Clear the shutdown flag App.clearShutdown(); + // For check shutdown + super.onResume(); + + new UriIntentInitTask(this, mRememberKeyfile) + .execute(getIntent()); + } + + @Override + public void onPostInitTask(Uri dbUri, Uri keyFileUri, Integer errorStringId) { + mDbUri = dbUri; + + if (errorStringId != null) { + Toast.makeText(PasswordActivity.this, errorStringId, Toast.LENGTH_LONG).show(); + finish(); + return; + } + + // Verify permission to read file + if (mDbUri != null + && !dbUri.getScheme().contains("content")) + PasswordActivityPermissionsDispatcher + .doNothingWithPermissionCheck(this); + + // Define title + String dbUriString = (mDbUri == null) ? "" : mDbUri.toString(); + if (!dbUriString.isEmpty()) { + if (PreferencesUtil.isFullFilePathEnable(this)) + filenameView.setText(dbUriString); + else + filenameView.setText(new File(mDbUri.getPath()).getName()); // TODO Encapsulate + } + + // Define Key File text + String keyUriString = (keyFileUri == null) ? "" : keyFileUri.toString(); + if (!keyUriString.isEmpty() && mRememberKeyfile) { // Bug KeepassDX #18 + keyFileView.setText(keyUriString); + } + + // Define listeners for default database checkbox and validate button + checkboxDefaultDatabaseView.setOnCheckedChangeListener(defaultCheckChange); + confirmButtonView.setOnClickListener(validateButtonViewClickListener); + + // Retrieve settings for default database + String defaultFilename = prefs.getString(KEY_DEFAULT_FILENAME, ""); + if (mDbUri!=null + && !EmptyUtils.isNullOrEmpty(mDbUri.getPath()) + && UriUtil.equalsDefaultfile(mDbUri, defaultFilename)) { + checkboxDefaultDatabaseView.setChecked(true); + } + // checks if fingerprint is available, will also start listening for fingerprints when available if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - initForFingerprint(); checkFingerprintAvailability(); if (fingerPrintAnimatedVector != null) { fingerPrintAnimatedVector.startScan(); } } + + // If Activity is launch with a password and want to open directly + Intent intent = getIntent(); + String password = intent.getStringExtra(KEY_PASSWORD); + boolean launch_immediately = intent.getBooleanExtra(KEY_LAUNCH_IMMEDIATELY, false); + + if (password != null) { + passwordView.setText(password); + } + if (launch_immediately) { + verifyCheckboxesAndLoadDatabase(password, keyFileUri); + } } private void setEmptyViews() { @@ -340,18 +359,10 @@ public class PasswordActivity extends LockingActivity } } - private Uri getKeyFile(Uri dbUri) { - if (mRememberKeyfile) { - return App.getFileHistory().getFileByName(dbUri); - } else { - return null; - } - } - // fingerprint related code here @RequiresApi(api = Build.VERSION_CODES.M) private void initForFingerprint() { - mode = -1; + fingerPrintMode = NOT_CONFIGURED_MODE; fingerPrintHelper = new FingerPrintHelper(this, this); @@ -377,7 +388,10 @@ public class PasswordActivity extends LockingActivity final boolean validInput = s.length() > 0; // encrypt or decrypt mode based on how much input or not setFingerPrintTextView(validInput ? R.string.store_with_fingerprint : R.string.scanning_fingerprint); - mode = validInput ? toggleMode(Cipher.ENCRYPT_MODE) : toggleMode(Cipher.DECRYPT_MODE); + if (validInput) + toggleFingerprintMode(STORE_MODE); + else + toggleFingerprintMode(OPEN_MODE); } } }); @@ -388,48 +402,40 @@ public class PasswordActivity extends LockingActivity public void onAuthenticationError( final int errorCode, final CharSequence errString) { - - // this is triggered on stop/start listening done by helper to switch between modes so don't restart here - // errorCode = 5 - // errString = "Fingerprint operation canceled." - //onFingerprintException(); - //fingerprintTextView.setText(errString); - // true false fingerprint readings are handled otherwise with the toast messages, see below in code + Log.i(getClass().getName(), errString.toString()); } @Override public void onAuthenticationHelp( final int helpCode, final CharSequence helpString) { - showError(helpString); - checkFingerprintAvailability(); + reInitWithSameFingerprintMode(); fingerprintTextView.setText(helpString); } - @Override - public void onAuthenticationSucceeded(final FingerprintManagerCompat.AuthenticationResult result) { - - if (mode == Cipher.ENCRYPT_MODE) { - - // newly store the entered password in encrypted way - final String password = passwordView.getText().toString(); - fingerPrintHelper.encryptData(password); - - } else if (mode == Cipher.DECRYPT_MODE) { - - // retrieve the encrypted value from preferences - final String encryptedValue = prefsNoBackup.getString(getPreferenceKeyValue(), null); - if (encryptedValue != null) { - fingerPrintHelper.decryptData(encryptedValue); - } - } - } - @Override public void onAuthenticationFailed() { showError(R.string.fingerprint_not_recognized); - checkFingerprintAvailability(); + reInitWithSameFingerprintMode(); + } + + @Override + public void onAuthenticationSucceeded(final FingerprintManagerCompat.AuthenticationResult result) { + switch (fingerPrintMode) { + case STORE_MODE: + // newly store the entered password in encrypted way + final String password = passwordView.getText().toString(); + fingerPrintHelper.encryptData(password); + break; + case OPEN_MODE: + // retrieve the encrypted value from preferences + final String encryptedValue = prefsNoBackup.getString(getPreferenceKeyValue(), null); + if (encryptedValue != null) { + fingerPrintHelper.decryptData(encryptedValue); + } + break; + } } }); } @@ -444,35 +450,59 @@ public class PasswordActivity extends LockingActivity } @RequiresApi(api = Build.VERSION_CODES.M) - private synchronized int toggleMode(final int newMode) { - if(newMode != mode) { - mode = newMode; - switch (mode) { - case Cipher.ENCRYPT_MODE: - fingerPrintHelper.initEncryptData(); - break; - case Cipher.DECRYPT_MODE: - final String ivSpecValue = prefsNoBackup.getString(getPreferenceKeyIvSpec(), null); - if (ivSpecValue != null) - fingerPrintHelper.initDecryptData(ivSpecValue); - break; - } + private void initEncryptData() { + setFingerPrintTextView(R.string.store_with_fingerprint); + fingerPrintMode = STORE_MODE; + if (fingerPrintHelper != null) + fingerPrintHelper.initEncryptData(); + } + + @RequiresApi(api = Build.VERSION_CODES.M) + private void initDecryptData() { + setFingerPrintTextView(R.string.scanning_fingerprint); + fingerPrintMode = OPEN_MODE; + if (fingerPrintHelper != null) { + final String ivSpecValue = prefsNoBackup.getString(getPreferenceKeyIvSpec(), null); + if (ivSpecValue != null) + fingerPrintHelper.initDecryptData(ivSpecValue); } - return newMode; + } + + @RequiresApi(api = Build.VERSION_CODES.M) + private synchronized void toggleFingerprintMode(final FingerPrintHelper.Mode newMode) { + if( !newMode.equals(fingerPrintMode) ) { + fingerPrintMode = newMode; + reInitWithSameFingerprintMode(); + } + } + + @RequiresApi(api = Build.VERSION_CODES.M) + private synchronized void reInitWithSameFingerprintMode() { + switch (fingerPrintMode) { + case STORE_MODE: + initEncryptData(); + break; + case OPEN_MODE: + initDecryptData(); + break; + } + // Show fingerprint key deletion + invalidateOptionsMenu(); } @Override protected void onPause() { super.onPause(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M - && fingerPrintAnimatedVector != null) { - fingerPrintAnimatedVector.stopScan(); - } - - // stop listening when we go in background - if (fingerPrintHelper != null) { - fingerPrintHelper.stopListening(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (fingerPrintAnimatedVector != null) { + fingerPrintAnimatedVector.stopScan(); + } + // stop listening when we go in background + fingerPrintMode = NOT_CONFIGURED_MODE; + if (fingerPrintHelper != null) { + fingerPrintHelper.stopListening(); + } } } @@ -498,14 +528,13 @@ public class PasswordActivity extends LockingActivity runOnUiThread(new Runnable() { @Override public void run() { - fingerprintImageView.setAlpha(alpha); + fingerprintContainerView.setAlpha(alpha); } }); } @RequiresApi(api = Build.VERSION_CODES.M) private synchronized void checkFingerprintAvailability() { - // fingerprint not supported (by API level or hardware) so keep option hidden // or manually disable if (!PreferencesUtil .isFingerprintEnable(getApplicationContext()) @@ -525,7 +554,7 @@ public class PasswordActivity extends LockingActivity setFingerPrintVisibility(View.VISIBLE); if (!fingerPrintHelper.hasEnrolledFingerprints()) { - setFingerPrintAlphaImageView(0.3f); + setFingerPrintAlphaImageView(0.6f); // This happens when no fingerprints are registered. Listening won't start setFingerPrintTextView(R.string.configure_fingerprint); } @@ -538,16 +567,25 @@ public class PasswordActivity extends LockingActivity if (!prefsNoBackup.contains(getPreferenceKeyValue())) { setFingerPrintTextView(R.string.no_password_stored); // listen for encryption - toggleMode(Cipher.ENCRYPT_MODE); + initEncryptData(); } // all is set here so we can confirm to user and start listening for fingerprints else { - setFingerPrintTextView(R.string.scanning_fingerprint); // listen for decryption - toggleMode(Cipher.DECRYPT_MODE); + initDecryptData(); } } } + + // Show fingerprint key deletion + invalidateOptionsMenu(); + } + + private void removePrefsNoBackupKeys() { + prefsNoBackup.edit() + .remove(getPreferenceKeyValue()) + .remove(getPreferenceKeyIvSpec()) + .apply(); } @Override @@ -559,7 +597,7 @@ public class PasswordActivity extends LockingActivity .putString(getPreferenceKeyIvSpec(), ivSpec) .apply(); // and remove visual input to reset UI - confirmButtonView.performClick(); + confirmButtonView.performClick(); // TODO remove click setFingerPrintTextView(R.string.encrypted_value_stored); } @@ -574,12 +612,9 @@ public class PasswordActivity extends LockingActivity @Override public void onInvalidKeyException(Exception e) { showError(R.string.fingerprint_invalid_key); - prefsNoBackup.edit() - .remove(getPreferenceKeyValue()) - .remove(getPreferenceKeyIvSpec()) - .apply(); + removePrefsNoBackupKeys(); e.printStackTrace(); - checkFingerprintAvailability(); // restarts listening + reInitWithSameFingerprintMode(); // restarts listening } @RequiresApi(api = Build.VERSION_CODES.M) @@ -587,7 +622,7 @@ public class PasswordActivity extends LockingActivity public void onFingerPrintException(Exception e) { showError(R.string.fingerprint_error); e.printStackTrace(); - checkFingerprintAvailability(); + reInitWithSameFingerprintMode(); } private void showError(final int messageId) { @@ -609,18 +644,14 @@ public class PasswordActivity extends LockingActivity } private class DefaultCheckChange implements CompoundButton.OnCheckedChangeListener { - @Override public void onCheckedChanged( CompoundButton buttonView, boolean isChecked) { - String newDefaultFileName; - + String newDefaultFileName = ""; if (isChecked) { newDefaultFileName = mDbUri.toString(); - } else { - newDefaultFileName = ""; } SharedPreferences.Editor editor = prefs.edit(); @@ -629,13 +660,10 @@ public class PasswordActivity extends LockingActivity BackupManagerCompat backupManager = new BackupManagerCompat(PasswordActivity.this); backupManager.dataChanged(); - } - } - private class OkClickHandler implements View.OnClickListener { - + private class ValidateButtonViewClickListener implements View.OnClickListener { public void onClick(View view) { String pass = passwordView.getText().toString(); String key = keyFileView.getText().toString(); @@ -689,7 +717,11 @@ public class PasswordActivity extends LockingActivity @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); - MenuUtil.defaultMenuInflater(getMenuInflater(), menu); + MenuInflater inflater = getMenuInflater(); + MenuUtil.defaultMenuInflater(inflater, menu); + if (!fingerprintMustBeConfigured + && prefsNoBackup.contains(getPreferenceKeyValue()) ) + inflater.inflate(R.menu.fingerprint, menu); return true; } @@ -700,7 +732,14 @@ public class PasswordActivity extends LockingActivity case android.R.id.home: finish(); break; - + case R.id.menu_fingerprint_remove_key: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + fingerPrintHelper.deleteEntryKey(); + removePrefsNoBackupKeys(); + fingerPrintMode = NOT_CONFIGURED_MODE; + checkFingerprintAvailability(); + } + break; default: return MenuUtil.onDefaultMenuOptionsItemSelected(this, item); } @@ -708,7 +747,17 @@ public class PasswordActivity extends LockingActivity return super.onOptionsItemSelected(item); } - private class AfterLoad extends OnFinish { + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + // NOTE: delegate the permission handling to generated method + PasswordActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults); + } + + /** + * Called after verify and try to opening the database + */ + private final class AfterLoad extends OnFinish { protected Database db; @@ -722,6 +771,16 @@ public class PasswordActivity extends LockingActivity @Override public void run() { + + // Recheck fingerprint if error + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + //setEmptyViews(); + //mMessage = getString(R.string.fingerprint_error) + " : " + mMessage; + // TODO Change fingerprint message + // Stay with the same mode + reInitWithSameFingerprintMode(); + } + if (db.passwordEncodingError) { PasswordEncodingDialogHelper dialog = new PasswordEncodingDialogHelper(); dialog.show(PasswordActivity.this, new OnClickListener() { @@ -730,12 +789,14 @@ public class PasswordActivity extends LockingActivity public void onClick( DialogInterface dialog, int which) { - GroupActivity.Launch(PasswordActivity.this, getIntent().getExtras()); + // TODO GroupActivity.launch(PasswordActivity.this, getIntent().getExtras()); + GroupActivity.Launch(PasswordActivity.this); } }); } else if (mSuccess) { - GroupActivity.Launch(PasswordActivity.this, getIntent().getExtras()); + // TODO GroupActivity.launch(PasswordActivity.this, getIntent().getExtras()); + GroupActivity.Launch(PasswordActivity.this); } else { displayMessage(PasswordActivity.this); } @@ -794,7 +855,6 @@ public class PasswordActivity extends LockingActivity return R.string.error_can_not_handle_uri; } - } else { databaseUri = UriUtil.parseDefaultFile(intent.getStringExtra(KEY_FILENAME)); keyFileUri = UriUtil.parseDefaultFile(intent.getStringExtra(KEY_KEYFILE)); @@ -818,4 +878,38 @@ public class PasswordActivity extends LockingActivity } } } + + @NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) + public void doNothing() {} + + @OnShowRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE) + void showRationaleForExternalStorage(final PermissionRequest request) { + new AlertDialog.Builder(this) + .setMessage(R.string.permission_external_storage_rationale_read_database) + .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + request.proceed(); + } + }) + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + request.cancel(); + } + }) + .show(); + } + + @OnPermissionDenied(Manifest.permission.WRITE_EXTERNAL_STORAGE) + void showDeniedForExternalStorage() { + Toast.makeText(this, R.string.permission_external_storage_denied, Toast.LENGTH_SHORT).show(); + finish(); + } + + @OnNeverAskAgain(Manifest.permission.WRITE_EXTERNAL_STORAGE) + void showNeverAskForExternalStorage() { + Toast.makeText(this, R.string.permission_external_storage_never_ask, Toast.LENGTH_SHORT).show(); + finish(); + } } diff --git a/app/src/main/java/com/keepassdroid/UriIntentInitTaskCallback.java b/app/src/main/java/com/keepassdroid/password/UriIntentInitTaskCallback.java similarity index 80% rename from app/src/main/java/com/keepassdroid/UriIntentInitTaskCallback.java rename to app/src/main/java/com/keepassdroid/password/UriIntentInitTaskCallback.java index 846488712..52eeef9ea 100644 --- a/app/src/main/java/com/keepassdroid/UriIntentInitTaskCallback.java +++ b/app/src/main/java/com/keepassdroid/password/UriIntentInitTaskCallback.java @@ -1,4 +1,4 @@ -package com.keepassdroid; +package com.keepassdroid.password; import android.net.Uri; diff --git a/app/src/main/java/com/keepassdroid/search/SearchDbHelper.java b/app/src/main/java/com/keepassdroid/search/SearchDbHelper.java index ca98cef5c..3955b5bc9 100644 --- a/app/src/main/java/com/keepassdroid/search/SearchDbHelper.java +++ b/app/src/main/java/com/keepassdroid/search/SearchDbHelper.java @@ -24,7 +24,8 @@ import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.util.Log; -import com.keepassdroid.Database; +import com.kunzisoft.keepass.R; +import com.keepassdroid.database.Database; import com.keepassdroid.database.PwDatabase; import com.keepassdroid.database.PwDatabaseV3; import com.keepassdroid.database.PwDatabaseV4; @@ -32,7 +33,6 @@ import com.keepassdroid.database.PwEntry; import com.keepassdroid.database.PwGroup; import com.keepassdroid.database.PwGroupV3; import com.keepassdroid.database.PwGroupV4; -import com.kunzisoft.keepass.R; import java.util.ArrayList; import java.util.Iterator; diff --git a/app/src/main/java/com/keepassdroid/search/SearchResultsActivity.java b/app/src/main/java/com/keepassdroid/search/SearchResultsActivity.java index 7ee178a66..54ad34e0d 100644 --- a/app/src/main/java/com/keepassdroid/search/SearchResultsActivity.java +++ b/app/src/main/java/com/keepassdroid/search/SearchResultsActivity.java @@ -22,43 +22,27 @@ package com.keepassdroid.search; import android.app.SearchManager; import android.content.Intent; import android.os.Bundle; +import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import com.kunzisoft.keepass.KeePass; -import com.kunzisoft.keepass.R; -import com.keepassdroid.Database; -import com.keepassdroid.GroupBaseActivity; -import com.keepassdroid.PwGroupListAdapter; +import com.keepassdroid.activities.ListNodesActivity; import com.keepassdroid.app.App; +import com.keepassdroid.database.Database; +import com.keepassdroid.database.PwGroup; import com.keepassdroid.utils.MenuUtil; +import com.kunzisoft.keepass.R; -public class SearchResultsActivity extends GroupBaseActivity { - - private Database mDb; +public class SearchResultsActivity extends ListNodesActivity { - private View listView; - private View imageNotFoundView; + private RecyclerView listView; - @Override + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - if ( isFinishing() ) { - return; - } - - setResult(KeePass.EXIT_NORMAL); - - mDb = App.getDB(); - - // Likely the app has been killed exit the activity - if ( ! mDb.Loaded() ) { - finish(); - } setContentView(getLayoutInflater().inflate(R.layout.search_results, null)); @@ -69,13 +53,35 @@ public class SearchResultsActivity extends GroupBaseActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); - listView = findViewById(R.id.group_list); - imageNotFoundView = findViewById(R.id.img_not_found); + listView = (RecyclerView) findViewById(R.id.nodes_list); + View notFoundView = findViewById(R.id.not_found_container); - performSearch(getSearchStr(getIntent())); - + if ( mCurrentGroup == null || mCurrentGroup.numbersOfChildEntries() < 1 ) { + listView.setVisibility(View.GONE); + notFoundView.setVisibility(View.VISIBLE); + } else { + listView.setVisibility(View.VISIBLE); + notFoundView.setVisibility(View.GONE); + } + + setGroupTitle(); } + @Override + protected PwGroup initCurrentGroup() { + Database mDb = App.getDB(); + // Likely the app has been killed exit the activity + if ( ! mDb.Loaded() ) { + finish(); + } + return mDb.Search(getSearchStr(getIntent()).trim()); + } + + @Override + protected RecyclerView defineNodeList() { + return listView; + } + @Override public boolean onCreateOptionsMenu(Menu menu) { @@ -92,25 +98,8 @@ public class SearchResultsActivity extends GroupBaseActivity { case android.R.id.home: finish(); } - return super.onOptionsItemSelected(item); } - - private void performSearch(String query) { - mGroup = mDb.Search(query.trim()); - - if ( mGroup == null || mGroup.childEntries.size() < 1 ) { - listView.setVisibility(View.GONE); - imageNotFoundView.setVisibility(View.VISIBLE); - } else { - listView.setVisibility(View.VISIBLE); - imageNotFoundView.setVisibility(View.GONE); - } - - setGroupTitle(); - - setListAdapter(new PwGroupListAdapter(this, mGroup)); - } private String getSearchStr(Intent queryIntent) { // get and process search query here diff --git a/app/src/main/java/com/keepassdroid/settings/MainPreferenceFragment.java b/app/src/main/java/com/keepassdroid/settings/MainPreferenceFragment.java index 2add3aaa5..192c1432a 100644 --- a/app/src/main/java/com/keepassdroid/settings/MainPreferenceFragment.java +++ b/app/src/main/java/com/keepassdroid/settings/MainPreferenceFragment.java @@ -6,7 +6,7 @@ import android.support.v4.app.DialogFragment; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceFragmentCompat; -import com.keepassdroid.Database; +import com.keepassdroid.database.Database; import com.keepassdroid.app.App; import com.kunzisoft.keepass.R; diff --git a/app/src/main/java/com/keepassdroid/settings/NestedSettingsFragment.java b/app/src/main/java/com/keepassdroid/settings/NestedSettingsFragment.java index d4d385855..b567a01e5 100644 --- a/app/src/main/java/com/keepassdroid/settings/NestedSettingsFragment.java +++ b/app/src/main/java/com/keepassdroid/settings/NestedSettingsFragment.java @@ -24,6 +24,7 @@ import android.content.DialogInterface; import android.content.res.Resources; import android.os.Build; import android.os.Bundle; +import android.support.annotation.RequiresApi; import android.support.v14.preference.SwitchPreference; import android.support.v4.app.DialogFragment; import android.support.v4.hardware.fingerprint.FingerprintManagerCompat; @@ -33,8 +34,8 @@ import android.support.v7.preference.PreferenceFragmentCompat; import android.util.Log; import android.widget.Toast; -import com.keepassdroid.Database; -import com.keepassdroid.UnavailableFeatureDialog; +import com.keepassdroid.database.Database; +import com.keepassdroid.fragments.UnavailableFeatureDialogFragment; import com.keepassdroid.app.App; import com.keepassdroid.database.PwEncryptionAlgorithm; import com.keepassdroid.fingerprint.FingerPrintHelper; @@ -69,26 +70,21 @@ public class NestedSettingsFragment extends PreferenceFragmentCompat 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; }); @@ -100,15 +96,21 @@ public class NestedSettingsFragment extends PreferenceFragmentCompat return true; }); - SwitchPreference fingerprintEnablePreference = (SwitchPreference) findPreference(getString(R.string.fingerprint_enable_key)); - if (!FingerPrintHelper.isFingerprintSupported(FingerprintManagerCompat.from(getContext()))) { + 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.setDefaultValue(false); + fingerprintEnablePreference.setChecked(false); fingerprintEnablePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { ((SwitchPreference) preference).setChecked(false); - UnavailableFeatureDialog.getInstance(Build.VERSION_CODES.M) + UnavailableFeatureDialogFragment.getInstance(Build.VERSION_CODES.M) .show(getFragmentManager(), "unavailableFeatureDialog"); return false; } @@ -123,72 +125,88 @@ public class NestedSettingsFragment extends PreferenceFragmentCompat } Preference deleteKeysFingerprints = findPreference(getString(R.string.fingerprint_delete_all_key)); - deleteKeysFingerprints.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference 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() { - @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(), R.string.fingerprint_error, Toast.LENGTH_SHORT).show(); - } - }); - PreferencesUtil.deleteAllValuesFromNoBackupPreferences(getContext()); - } - }) - .setNegativeButton( - getResources().getString(android.R.string.no), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int which) { - } - }).show(); - return false; - } - }); + if (!fingerprintSupported) { + deleteKeysFingerprints.setEnabled(false); + } else { + deleteKeysFingerprints.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference 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(), R.string.fingerprint_error, Toast.LENGTH_SHORT).show(); + } + }); + PreferencesUtil.deleteAllValuesFromNoBackupPreferences(getContext()); + } + }) + .setNegativeButton( + getResources().getString(android.R.string.no), + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + } + }).show(); + return false; + } + }); + } break; case NESTED_SCREEN_DB_KEY: setPreferencesFromResource(R.xml.db_preferences, rootKey); Database db = App.getDB(); - Preference algorithmPref = findPreference(getString(R.string.algorithm_key)); - Preference roundPref = findPreference(getString(R.string.rounds_key)); + if (db.Loaded()) { + if (db.pm.algorithmSettingsEnabled()) { - if (!(db.Loaded() && db.pm.appSettingsEnabled())) { - algorithmPref.setEnabled(false); - roundPref.setEnabled(false); - } + 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()); + } - if (db.Loaded() && db.pm.appSettingsEnabled()) { - roundPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - public boolean onPreferenceChange(Preference preference, Object newValue) { - setRounds(App.getDB(), preference); - return true; - } - }); - setRounds(db, roundPref); - setAlgorithm(db, algorithmPref); } else { Log.e(getClass().getName(), "Database isn't ready"); } + + break; default: diff --git a/app/src/main/java/com/keepassdroid/settings/PreferencesUtil.java b/app/src/main/java/com/keepassdroid/settings/PreferencesUtil.java index db3702b29..3eb5c89a9 100644 --- a/app/src/main/java/com/keepassdroid/settings/PreferencesUtil.java +++ b/app/src/main/java/com/keepassdroid/settings/PreferencesUtil.java @@ -23,6 +23,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; +import com.keepassdroid.database.SortNodeEnum; import com.kunzisoft.keepass.R; import java.util.Arrays; @@ -88,4 +89,40 @@ public class PreferencesUtil { return prefs.getBoolean(ctx.getString(R.string.full_file_path_enable_key), ctx.getResources().getBoolean(R.bool.full_file_path_enable_default)); } + + public static SortNodeEnum getListSort(Context ctx) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); + return SortNodeEnum.valueOf(prefs.getString(ctx.getString(R.string.sort_node_key), + SortNodeEnum.TITLE.name())); + } + + public static boolean getGroupsBeforeSort(Context ctx) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); + return prefs.getBoolean(ctx.getString(R.string.sort_group_before_key), + ctx.getResources().getBoolean(R.bool.sort_group_before_default)); + } + + public static boolean getAscendingSort(Context ctx) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); + return prefs.getBoolean(ctx.getString(R.string.sort_ascending_key), + ctx.getResources().getBoolean(R.bool.sort_ascending_default)); + } + + public static boolean getRecycleBinBottomSort(Context ctx) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); + return prefs.getBoolean(ctx.getString(R.string.sort_recycle_bin_bottom_key), + ctx.getResources().getBoolean(R.bool.sort_recycle_bin_bottom_default)); + } + + public static boolean isPasswordMask(Context ctx) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); + return prefs.getBoolean(ctx.getString(R.string.maskpass_key), + ctx.getResources().getBoolean(R.bool.maskpass_default)); + } + + public static boolean fieldFontIsInVisibility(Context ctx) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); + return prefs.getBoolean(ctx.getString(R.string.monospace_font_fields_enable_key), + ctx.getResources().getBoolean(R.bool.monospace_font_fields_enable_default)); + } } diff --git a/app/src/main/java/com/keepassdroid/settings/RoundsPreferenceDialogFragmentCompat.java b/app/src/main/java/com/keepassdroid/settings/RoundsPreferenceDialogFragmentCompat.java index 6bffa6d67..1a7f4fc64 100644 --- a/app/src/main/java/com/keepassdroid/settings/RoundsPreferenceDialogFragmentCompat.java +++ b/app/src/main/java/com/keepassdroid/settings/RoundsPreferenceDialogFragmentCompat.java @@ -9,8 +9,8 @@ import android.view.View; import android.widget.TextView; import android.widget.Toast; -import com.keepassdroid.Database; -import com.keepassdroid.ProgressTask; +import com.keepassdroid.database.Database; +import com.keepassdroid.tasks.ProgressTask; import com.keepassdroid.app.App; import com.keepassdroid.database.PwDatabase; import com.keepassdroid.database.edit.OnFinish; diff --git a/app/src/main/java/com/keepassdroid/settings/SettingsActivity.java b/app/src/main/java/com/keepassdroid/settings/SettingsActivity.java index 5373e6b07..a8389ab12 100644 --- a/app/src/main/java/com/keepassdroid/settings/SettingsActivity.java +++ b/app/src/main/java/com/keepassdroid/settings/SettingsActivity.java @@ -23,13 +23,13 @@ import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.MenuItem; -import com.kunzisoft.keepass.R; +import com.keepassdroid.activities.LockingActivity; +import com.keepassdroid.app.App; import com.keepassdroid.compat.BackupManagerCompat; -import com.keepassdroid.stylish.StylishActivity; -import com.keepassdroid.timeout.TimeoutHelper; +import com.kunzisoft.keepass.R; -public class SettingsActivity extends StylishActivity implements MainPreferenceFragment.Callback { +public class SettingsActivity extends LockingActivity implements MainPreferenceFragment.Callback { private static final String TAG_NESTED = "TAG_NESTED"; @@ -37,19 +37,13 @@ public class SettingsActivity extends StylishActivity implements MainPreferenceF private Toolbar toolbar; - @Override - protected void onPause() { - super.onPause(); - - TimeoutHelper.pause(this); - } - @Override protected void onResume() { - super.onResume(); - TimeoutHelper.resume(this); - TimeoutHelper.checkShutdown(this); + // Clear the shutdown flag + App.clearShutdown(); + + super.onResume(); } @Override diff --git a/app/src/main/java/com/keepassdroid/ProgressTask.java b/app/src/main/java/com/keepassdroid/tasks/ProgressTask.java similarity index 98% rename from app/src/main/java/com/keepassdroid/ProgressTask.java rename to app/src/main/java/com/keepassdroid/tasks/ProgressTask.java index 1af50eef9..58c08e382 100644 --- a/app/src/main/java/com/keepassdroid/ProgressTask.java +++ b/app/src/main/java/com/keepassdroid/tasks/ProgressTask.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.tasks; import android.app.ProgressDialog; import android.content.Context; diff --git a/app/src/main/java/com/keepassdroid/UIToastTask.java b/app/src/main/java/com/keepassdroid/tasks/UIToastTask.java similarity index 97% rename from app/src/main/java/com/keepassdroid/UIToastTask.java rename to app/src/main/java/com/keepassdroid/tasks/UIToastTask.java index 7f95f8a45..68f245bd3 100644 --- a/app/src/main/java/com/keepassdroid/UIToastTask.java +++ b/app/src/main/java/com/keepassdroid/tasks/UIToastTask.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.tasks; import android.content.Context; import android.widget.Toast; diff --git a/app/src/main/java/com/keepassdroid/UpdateStatus.java b/app/src/main/java/com/keepassdroid/tasks/UpdateStatus.java similarity index 97% rename from app/src/main/java/com/keepassdroid/UpdateStatus.java rename to app/src/main/java/com/keepassdroid/tasks/UpdateStatus.java index 06444f24a..9b31e6d88 100644 --- a/app/src/main/java/com/keepassdroid/UpdateStatus.java +++ b/app/src/main/java/com/keepassdroid/tasks/UpdateStatus.java @@ -17,7 +17,7 @@ * along with KeePass DX. If not, see . * */ -package com.keepassdroid; +package com.keepassdroid.tasks; import android.app.ProgressDialog; import android.content.Context; diff --git a/app/src/main/java/com/keepassdroid/utils/MenuUtil.java b/app/src/main/java/com/keepassdroid/utils/MenuUtil.java index 132312b23..605841225 100644 --- a/app/src/main/java/com/keepassdroid/utils/MenuUtil.java +++ b/app/src/main/java/com/keepassdroid/utils/MenuUtil.java @@ -9,7 +9,7 @@ import android.widget.Toast; import com.kunzisoft.keepass.BuildConfig; import com.kunzisoft.keepass.R; -import com.keepassdroid.AboutActivity; +import com.keepassdroid.activities.AboutActivity; import com.keepassdroid.settings.SettingsActivity; import com.keepassdroid.stylish.StylishActivity; diff --git a/app/src/main/java/com/keepassdroid/utils/Util.java b/app/src/main/java/com/keepassdroid/utils/Util.java index ffb0d7adb..3a060441b 100644 --- a/app/src/main/java/com/keepassdroid/utils/Util.java +++ b/app/src/main/java/com/keepassdroid/utils/Util.java @@ -19,10 +19,10 @@ */ package com.keepassdroid.utils; -import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; +import android.graphics.Typeface; import android.net.Uri; import android.text.ClipboardManager; import android.widget.TextView; @@ -40,13 +40,13 @@ public class Util { if (csText == null) { return ""; } - + return csText.toString(); } - + public static void copyToClipboard(Context context, String text) throws SamsungClipboardException { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); - + try { clipboard.setText(text); } catch (NullPointerException e) { @@ -64,16 +64,6 @@ public class Util { public static void gotoUrl(Context context, int resId) throws ActivityNotFoundException { gotoUrl(context, context.getString(resId)); } - - public static String getEditText(Activity act, int resId) { - TextView te = (TextView) act.findViewById(resId); - - if (te != null) { - return te.getText().toString(); - } else { - return ""; - } - } public static void copyStream(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[1024]; @@ -83,4 +73,9 @@ public class Util { } } + public static void applyFontVisibilityToTextView(boolean applyMonospace, TextView textView) { + if (applyMonospace) + textView.setTypeface(Typeface.MONOSPACE); + } + } diff --git a/app/src/main/java/com/keepassdroid/view/AssignPasswordHelper.java b/app/src/main/java/com/keepassdroid/view/AssignPasswordHelper.java index 878957f8d..278a7b3eb 100644 --- a/app/src/main/java/com/keepassdroid/view/AssignPasswordHelper.java +++ b/app/src/main/java/com/keepassdroid/view/AssignPasswordHelper.java @@ -6,7 +6,7 @@ import android.content.DialogInterface; import android.net.Uri; import android.os.Handler; -import com.keepassdroid.ProgressTask; +import com.keepassdroid.tasks.ProgressTask; import com.keepassdroid.app.App; import com.keepassdroid.database.edit.FileOnFinish; import com.keepassdroid.database.edit.OnFinish; diff --git a/app/src/main/java/com/keepassdroid/view/EntryContentsView.java b/app/src/main/java/com/keepassdroid/view/EntryContentsView.java index d81985c81..cd914c941 100644 --- a/app/src/main/java/com/keepassdroid/view/EntryContentsView.java +++ b/app/src/main/java/com/keepassdroid/view/EntryContentsView.java @@ -20,29 +20,179 @@ package com.keepassdroid.view; import android.content.Context; +import android.text.method.PasswordTransformationMethod; import android.util.AttributeSet; import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.TextView; +import com.keepassdroid.utils.Util; import com.kunzisoft.keepass.R; +import java.text.DateFormat; +import java.util.Date; + public class EntryContentsView extends LinearLayout { - + + private boolean fontInVisibility; + + private View userNameContainerView; + private TextView userNameView; + private ImageView userNameActionView; + + private View passwordContainerView; + private TextView passwordView; + private ImageView passwordActionView; + + private View urlContainerView; + private TextView urlView; + + private View commentContainerView; + private TextView commentView; + + private ViewGroup extrasView; + + private DateFormat dateFormat; + private DateFormat timeFormat; + + private TextView creationDateView; + private TextView modificationDateView; + private TextView lastAccessDateView; + private TextView expiresDateView; + public EntryContentsView(Context context) { this(context, null); } public EntryContentsView(Context context, AttributeSet attrs) { super(context, attrs); + + fontInVisibility = false; + + dateFormat = android.text.format.DateFormat.getDateFormat(context); + timeFormat = android.text.format.DateFormat.getTimeFormat(context); inflate(context); } private void inflate(Context context) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + assert inflater != null; inflater.inflate(R.layout.entry_view_contents, this); + + userNameContainerView = findViewById(R.id.entry_user_name_container); + userNameView = (TextView) findViewById(R.id.entry_user_name); + userNameActionView = (ImageView) findViewById(R.id.entry_user_name_action_image); + + passwordContainerView = findViewById(R.id.entry_password_container); + passwordView = (TextView) findViewById(R.id.entry_password); + passwordActionView = (ImageView) findViewById(R.id.entry_password_action_image); + + urlContainerView = findViewById(R.id.entry_url_container); + urlView = (TextView) findViewById(R.id.entry_url); + + commentContainerView = findViewById(R.id.entry_comment_container); + commentView = (TextView) findViewById(R.id.entry_comment); + + extrasView = (ViewGroup) findViewById(R.id.extra_strings); + + creationDateView = (TextView) findViewById(R.id.entry_created); + modificationDateView = (TextView) findViewById(R.id.entry_modified); + lastAccessDateView = (TextView) findViewById(R.id.entry_accessed); + expiresDateView = (TextView) findViewById(R.id.entry_expires); } + public void applyFontVisibilityToFields(boolean fontInVisibility) { + this.fontInVisibility = fontInVisibility; + } + + public void assignUserName(String userName) { + if (userName != null && !userName.isEmpty()) { + userNameContainerView.setVisibility(VISIBLE); + userNameView.setText(userName); + } + } + + public void assignUserNameCopyListener(OnClickListener onClickListener) { + userNameActionView.setOnClickListener(onClickListener); + } + + public void assignPassword(String password) { + if (password != null && !password.isEmpty()) { + passwordContainerView.setVisibility(VISIBLE); + passwordView.setText(password); + } + } + + public void assignPasswordCopyListener(OnClickListener onClickListener) { + passwordActionView.setOnClickListener(onClickListener); + } + + public boolean isPasswordPresent() { + return passwordContainerView.getVisibility() == VISIBLE; + } + + public void setHiddenPasswordStyle(boolean hiddenStyle) { + if ( !hiddenStyle ) { + passwordView.setTransformationMethod(null); + } else { + passwordView.setTransformationMethod(PasswordTransformationMethod.getInstance()); + } + } + + public void assignURL(String url) { + if (url != null && !url.isEmpty()) { + urlContainerView.setVisibility(VISIBLE); + urlView.setText(url); + } + } + + + public void assignComment(String comment) { + if (comment != null && !comment.isEmpty()) { + commentContainerView.setVisibility(VISIBLE); + Util.applyFontVisibilityToTextView(fontInVisibility, commentView); + commentView.setText(comment); + } + } + + public void addExtraField(String title, String value, OnClickListener onActionClickListener) { + EntryNewField entryNewField = new EntryNewField(getContext(), null, title, value, onActionClickListener); + entryNewField.applyFontVisibilityToValue(fontInVisibility); + extrasView.addView(entryNewField); + } + + public void clearExtraFields() { + extrasView.removeAllViews(); + } + + private String getDateTime(Date date) { + return dateFormat.format(date) + " " + timeFormat.format(date); + } + + public void assignCreationDate(Date date) { + creationDateView.setText(getDateTime(date)); + } + + public void assignModificationDate(Date date) { + modificationDateView.setText(getDateTime(date)); + } + + public void assignLastAccessDate(Date date) { + lastAccessDateView.setText(getDateTime(date)); + } + + public void assignExpiresDate(Date date) { + expiresDateView.setText(getDateTime(date)); + } + + public void assignExpiresDate(String constString) { + expiresDateView.setText(constString); + } + @Override protected LayoutParams generateDefaultLayoutParams() { return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); diff --git a/app/src/main/java/com/keepassdroid/view/EntryEditNewField.java b/app/src/main/java/com/keepassdroid/view/EntryEditNewField.java new file mode 100644 index 000000000..e0326bff9 --- /dev/null +++ b/app/src/main/java/com/keepassdroid/view/EntryEditNewField.java @@ -0,0 +1,104 @@ +/* + * Copyright 2017 Brian Pellin, 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.content.Context; +import android.util.AttributeSet; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CompoundButton; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.keepassdroid.database.security.ProtectedString; +import com.keepassdroid.utils.Util; +import com.kunzisoft.keepass.R; + +public class EntryEditNewField extends RelativeLayout { + + private TextView labelView; + private TextView valueView; + private CompoundButton protectionCheckView; + + public EntryEditNewField(Context context) { + this(context, null); + } + + public EntryEditNewField(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public EntryEditNewField(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + assert inflater != null; + inflater.inflate(R.layout.entry_edit_new_field, this); + + View deleteView = findViewById(R.id.entry_edit_new_field_delete); + deleteView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + deleteViewFromParent(); + } + }); + + labelView = (TextView) findViewById(R.id.entry_edit_new_field_label); + valueView = (TextView) findViewById(R.id.entry_edit_new_field_value); + protectionCheckView = (CompoundButton) findViewById(R.id.protection); + } + + public void setData(String label, ProtectedString value) { + if (label != null) + labelView.setText(label); + if (value != null) { + valueView.setText(value.toString()); + protectionCheckView.setChecked(value.isProtected()); + } + } + + public String getLabel() { + return labelView.getText().toString(); + } + + public String getValue() { + return valueView.getText().toString(); + } + + public boolean isProtected() { + return protectionCheckView.isChecked(); + } + + public void setFontVisibility(boolean applyFontVisibility) { + Util.applyFontVisibilityToTextView(applyFontVisibility, valueView); + } + + public void deleteViewFromParent() { + try { + ViewGroup parent = (ViewGroup) getParent(); + parent.removeView(this); + parent.invalidate(); + } catch (ClassCastException e) { + Log.e(getClass().getName(), e.getMessage()); + } + } +} diff --git a/app/src/main/java/com/keepassdroid/view/EntryEditSection.java b/app/src/main/java/com/keepassdroid/view/EntryEditSection.java deleted file mode 100644 index e458bc23b..000000000 --- a/app/src/main/java/com/keepassdroid/view/EntryEditSection.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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.content.Context; -import android.util.AttributeSet; -import android.widget.CheckBox; -import android.widget.RelativeLayout; -import android.widget.TextView; - -import com.kunzisoft.keepass.R; -import com.keepassdroid.database.security.ProtectedString; - -public class EntryEditSection extends RelativeLayout { - - public EntryEditSection(Context context) { - super(context); - } - - public EntryEditSection(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public EntryEditSection(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public void setData(String title, ProtectedString value) { - setText(R.id.title, title); - setText(R.id.value, value.toString()); - - CheckBox cb = (CheckBox) findViewById(R.id.protection); - cb.setChecked(value.isProtected()); - } - - private void setText(int resId, String str) { - if (str != null) { - TextView tvTitle = (TextView) findViewById(resId); - tvTitle.setText(str); - } - - } -} diff --git a/app/src/main/java/com/keepassdroid/view/EntryNewField.java b/app/src/main/java/com/keepassdroid/view/EntryNewField.java new file mode 100644 index 000000000..59f857d1d --- /dev/null +++ b/app/src/main/java/com/keepassdroid/view/EntryNewField.java @@ -0,0 +1,89 @@ +/* + * Copyright 2017 Brian Pellin, 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.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.keepassdroid.utils.Util; +import com.kunzisoft.keepass.R; + +public class EntryNewField extends LinearLayout { + + private TextView labelView; + private TextView valueView; + private ImageView actionImageView; + + public EntryNewField(Context context) { + this(context, null); + } + + public EntryNewField(Context context, AttributeSet attrs) { + this(context, attrs, null, null); + } + + public EntryNewField(Context context, AttributeSet attrs, String title, String value) { + this(context, attrs, title, value, null); + } + + public EntryNewField(Context context, AttributeSet attrs, String label, String value, OnClickListener onClickActionListener) { + super(context, attrs); + + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + assert inflater != null; + inflater.inflate(R.layout.entry_new_field, this); + + labelView = (TextView) findViewById(R.id.title); + valueView = (TextView) findViewById(R.id.value); + actionImageView = (ImageView) findViewById(R.id.action_image); + + setLabel(label); + setValue(value); + setAction(onClickActionListener); + } + + public void applyFontVisibilityToValue(boolean changeFont) { + Util.applyFontVisibilityToTextView(changeFont, valueView); + } + + public void setLabel(String label) { + if (label != null) { + labelView.setText(label); + } + } + + public void setValue(String value) { + if (value != null) { + valueView.setText(value); + } + } + + public void setAction(OnClickListener onClickListener) { + if (onClickListener != null) { + actionImageView.setOnClickListener(onClickListener); + } else { + actionImageView.setVisibility(GONE); + } + } +} diff --git a/app/src/main/java/com/keepassdroid/view/EntrySection.java b/app/src/main/java/com/keepassdroid/view/EntrySection.java deleted file mode 100644 index 7ec69121a..000000000 --- a/app/src/main/java/com/keepassdroid/view/EntrySection.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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.content.Context; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.kunzisoft.keepass.R; - -public class EntrySection extends LinearLayout { - - public EntrySection(Context context) { - this(context, null); - } - - public EntrySection(Context context, AttributeSet attrs) { - this(context, attrs, null, null); - } - - public EntrySection(Context context, AttributeSet attrs, String title, String value) { - super(context, attrs); - - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - inflate(inflater, context, title, value); - } - - protected int getLayout() { - return R.layout.entry_section; - } - - protected void inflate(LayoutInflater inflater, Context context, String title, String value) { - inflater.inflate(getLayout(), this); - - setText(R.id.title, title); - setText(R.id.value, value); - } - - private void setText(int resId, String str) { - if (str != null) { - TextView tvTitle = (TextView) findViewById(resId); - tvTitle.setText(str); - } - - } -} diff --git a/app/src/main/java/com/keepassdroid/view/GroupAddEntryView.java b/app/src/main/java/com/keepassdroid/view/GroupAddEntryView.java deleted file mode 100644 index 18c459d20..000000000 --- a/app/src/main/java/com/keepassdroid/view/GroupAddEntryView.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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.content.Context; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.animation.AccelerateDecelerateInterpolator; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.view.animation.RotateAnimation; -import android.widget.RelativeLayout; - -import com.kunzisoft.keepass.R; - -public class GroupAddEntryView extends RelativeLayout { - - protected View addButton; - - protected View addEntry; - protected boolean addEntryActivated; - protected View addGroup; - protected boolean addGroupActivated; - - - private boolean animInProgress; - private AddButtonAnimation viewButtonMenuAnimation; - private ViewMenuAnimation viewMenuAnimationAddEntry; - private ViewMenuAnimation viewMenuAnimationAddGroup; - - public GroupAddEntryView(Context context) { - this(context, null); - } - - public GroupAddEntryView(Context context, AttributeSet attrs) { - super(context, attrs); - - inflate(context); - } - - protected void inflate(Context context) { - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - inflater.inflate(R.layout.group_add_entry, this); - - addEntryActivated = true; - addGroupActivated = true; - - addButton = findViewById(R.id.add_button); - addEntry = findViewById(R.id.add_entry); - addGroup = findViewById(R.id.add_group); - - viewButtonMenuAnimation = new AddButtonAnimation(addButton); - viewMenuAnimationAddEntry = new ViewMenuAnimation(addEntry); - viewMenuAnimationAddGroup = new ViewMenuAnimation(addGroup); - - addButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if(!animInProgress) { - viewButtonMenuAnimation.startAnimation(); - if (addEntryActivated) { - viewMenuAnimationAddEntry.startAnimation(); - } - if (addGroupActivated) { - viewMenuAnimationAddGroup.startAnimation(); - } - } - } - }); - } - - private class AddButtonAnimation implements Animation.AnimationListener { - - private View view; - - private boolean isRotate; - - private Animation rightAnim; - private Animation leftAnim; - - AddButtonAnimation(View view) { - this.view = view; - - this.isRotate = false; - - rightAnim = new RotateAnimation(0f, 135f, - Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); - rightAnim.setDuration(300); - rightAnim.setInterpolator(new AccelerateDecelerateInterpolator()); - rightAnim.setFillAfter(true); - leftAnim = new RotateAnimation(135f, 0f, - Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); - leftAnim.setDuration(300); - leftAnim.setInterpolator(new AccelerateDecelerateInterpolator()); - leftAnim.setFillAfter(true); - - } - - @Override - public void onAnimationStart(Animation animation) { - animInProgress = true; - } - - @Override - public void onAnimationEnd(Animation animation) { - animInProgress = false; - isRotate = !isRotate; - } - - @Override - public void onAnimationRepeat(Animation animation) {} - - void startAnimation() { - Animation animation; - if(!isRotate) - animation = rightAnim; - else - animation = leftAnim; - animation.setAnimationListener(this); - view.startAnimation(animation); - } - } - - private class ViewMenuAnimation implements Animation.AnimationListener { - - private View view; - - private Animation animViewShow; - private Animation animViewHide; - - ViewMenuAnimation(View view) { - this.view = view; - - animViewShow = new AlphaAnimation(0.0f, 1.0f); - animViewShow.setDuration(300); - - animViewHide = new AlphaAnimation(1.0f, 0.0f); - animViewHide.setDuration(300); - } - - @Override - public void onAnimationStart(Animation animation) {} - - @Override - public void onAnimationEnd(Animation animation) { - if(view.getVisibility() == VISIBLE) - view.setVisibility(GONE); - else - view.setVisibility(VISIBLE); - } - - @Override - public void onAnimationRepeat(Animation animation) {} - - void startAnimation() { - Animation animation; - if(view.getVisibility() == VISIBLE) - animation = animViewHide; - else - animation = animViewShow; - animation.setAnimationListener(this); - view.startAnimation(animation); - } - } -} diff --git a/app/src/main/java/com/keepassdroid/view/GroupHeaderView.java b/app/src/main/java/com/keepassdroid/view/GroupHeaderView.java index cb6e2049a..b8166be2f 100644 --- a/app/src/main/java/com/keepassdroid/view/GroupHeaderView.java +++ b/app/src/main/java/com/keepassdroid/view/GroupHeaderView.java @@ -42,6 +42,7 @@ public class GroupHeaderView extends RelativeLayout { private void inflate(Context context) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + assert inflater != null; inflater.inflate(R.layout.group_header, this); if (App.getDB().readOnly) { diff --git a/app/src/main/java/com/keepassdroid/view/GroupRootView.java b/app/src/main/java/com/keepassdroid/view/GroupRootView.java deleted file mode 100644 index 14f473fd3..000000000 --- a/app/src/main/java/com/keepassdroid/view/GroupRootView.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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.content.Context; -import android.util.AttributeSet; - -public class GroupRootView extends GroupAddEntryView { - - public GroupRootView(Context context) { - this(context, null); - } - - public GroupRootView(Context context, AttributeSet attrs) { - super(context, attrs); - - inflate(context); - } - - @Override - protected void inflate(Context context) { - super.inflate(context); - - addEntryActivated = false; - } -} diff --git a/app/src/main/java/com/keepassdroid/view/GroupViewOnlyView.java b/app/src/main/java/com/keepassdroid/view/GroupViewOnlyView.java deleted file mode 100644 index 130399b18..000000000 --- a/app/src/main/java/com/keepassdroid/view/GroupViewOnlyView.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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.content.Context; -import android.util.AttributeSet; - -public class GroupViewOnlyView extends GroupAddEntryView { - - public GroupViewOnlyView(Context context) { - this(context, null); - } - - public GroupViewOnlyView(Context context, AttributeSet attrs) { - super(context, attrs); - - inflate(context); - } - - @Override - protected void inflate(Context context) { - super.inflate(context); - - // Hide the buttons - addButton.setVisibility(GONE); - } - -} diff --git a/app/src/main/java/com/keepassdroid/view/KeyFileHelper.java b/app/src/main/java/com/keepassdroid/view/KeyFileHelper.java index 5e7d570f6..0deddb549 100644 --- a/app/src/main/java/com/keepassdroid/view/KeyFileHelper.java +++ b/app/src/main/java/com/keepassdroid/view/KeyFileHelper.java @@ -21,22 +21,22 @@ package com.keepassdroid.view; import android.app.Activity; import android.content.ActivityNotFoundException; +import android.content.ContentResolver; import android.content.Intent; import android.net.Uri; import android.support.v4.app.Fragment; +import android.util.Log; import android.view.View; +import com.keepassdroid.compat.ContentResolverCompat; import com.keepassdroid.compat.StorageAF; import com.keepassdroid.fileselect.BrowserDialog; import com.keepassdroid.intents.Intents; import com.keepassdroid.utils.Interaction; import com.keepassdroid.utils.UriUtil; -import java.io.File; - import static android.app.Activity.RESULT_OK; - public class KeyFileHelper { public static final int GET_CONTENT = 25745; @@ -45,75 +45,88 @@ public class KeyFileHelper { private Activity activity; private Fragment fragment; - private Uri mDbUri; public KeyFileHelper(Activity context) { - this(context, null); - } - - public KeyFileHelper(Activity context, Uri mDbUri) { this.activity = context; this.fragment = null; - this.mDbUri = mDbUri; } public KeyFileHelper(Fragment context) { - this(context, null); - } - - public KeyFileHelper(Fragment context, Uri mDbUri) { this.activity = context.getActivity(); this.fragment = context; - this.mDbUri = mDbUri; } - public View.OnClickListener getOpenFileOnClickViewListener() { - return new View.OnClickListener() { + public class OpenFileOnClickViewListener implements View.OnClickListener { - public void onClick(View v) { - if (StorageAF.useStorageFramework(activity)) { - Intent i = new Intent(StorageAF.ACTION_OPEN_DOCUMENT); - i.addCategory(Intent.CATEGORY_OPENABLE); - i.setType("*/*"); + private ClickDataUriCallback dataUri; + + OpenFileOnClickViewListener(ClickDataUriCallback dataUri) { + this.dataUri = dataUri; + } + + @Override + public void onClick(View v) { + if (StorageAF.useStorageFramework(activity)) { + Intent i = new Intent(StorageAF.ACTION_OPEN_DOCUMENT); + i.addCategory(Intent.CATEGORY_OPENABLE); + i.setType("*/*"); + i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION| + Intent.FLAG_GRANT_WRITE_URI_PERMISSION| + Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); + if(fragment != null) + fragment.startActivityForResult(i, OPEN_DOC); + else + activity.startActivityForResult(i, OPEN_DOC); + } else { + Intent i = new Intent(Intent.ACTION_GET_CONTENT); + i.addCategory(Intent.CATEGORY_OPENABLE); + i.setType("*/*"); + + try { if(fragment != null) - fragment.startActivityForResult(i, OPEN_DOC); + fragment.startActivityForResult(i, GET_CONTENT); else - activity.startActivityForResult(i, OPEN_DOC); - } else { - Intent i = new Intent(Intent.ACTION_GET_CONTENT); - i.addCategory(Intent.CATEGORY_OPENABLE); - i.setType("*/*"); - - try { - if(fragment != null) - fragment.startActivityForResult(i, GET_CONTENT); - else - activity.startActivityForResult(i, GET_CONTENT); - } catch (ActivityNotFoundException e) { - lookForOpenIntentsFilePicker(); - } + activity.startActivityForResult(i, GET_CONTENT); + } catch (ActivityNotFoundException|SecurityException e) { + lookForOpenIntentsFilePicker(dataUri.onRequestIntentFilePicker()); } } - }; + } } - private void lookForOpenIntentsFilePicker() { + public OpenFileOnClickViewListener getOpenFileOnClickViewListener() { + return new OpenFileOnClickViewListener(null); + } + + public OpenFileOnClickViewListener getOpenFileOnClickViewListener(ClickDataUriCallback dataUri) { + return new OpenFileOnClickViewListener(dataUri); + } + + private void lookForOpenIntentsFilePicker(Uri dataUri) { if (Interaction.isIntentAvailable(activity, Intents.OPEN_INTENTS_FILE_BROWSE)) { Intent i = new Intent(Intents.OPEN_INTENTS_FILE_BROWSE); // Get file path parent if possible try { - if (mDbUri != null && mDbUri.toString().length() > 0) { - if (mDbUri.getScheme().equals("file")) { + if (dataUri != null + && dataUri.toString().length() > 0 + && dataUri.getScheme().equals("file")) { + i.setData(dataUri); + //i.setData(Uri.parse("file://" + mDbUri.getPath())); + /* + TODO Verify Intent File Picker File keyfile = new File(mDbUri.getPath()); File parent = keyfile.getParentFile(); if (parent != null) { i.setData(Uri.parse("file://" + parent.getAbsolutePath())); } - } + */ + } else { + Log.w(getClass().getName(), "Unable to read the URI"); } } catch (Exception e) { // Ignore + Log.w(getClass().getName(), "Unable to read the URI " + e.getMessage()); } try { @@ -134,7 +147,6 @@ public class KeyFileHelper { browserDialog.show(); } - public void onActivityResultCallback( int requestCode, int resultCode, @@ -159,6 +171,16 @@ public class KeyFileHelper { if (data != null) { Uri uri = data.getData(); if (uri != null) { + if (StorageAF.useStorageFramework(activity)) { + try { + // try to persist read and write permissions + ContentResolver resolver = activity.getContentResolver(); + ContentResolverCompat.takePersistableUriPermission(resolver, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); + ContentResolverCompat.takePersistableUriPermission(resolver, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + } catch (Exception e) { + // nop + } + } if (requestCode == GET_CONTENT) { uri = UriUtil.translate(activity, uri); } @@ -175,4 +197,8 @@ public class KeyFileHelper { void onKeyFileResultCallback(Uri uri); } + public interface ClickDataUriCallback { + Uri onRequestIntentFilePicker(); + } + } diff --git a/app/src/main/java/com/keepassdroid/view/ListNodesWithAddButtonView.java b/app/src/main/java/com/keepassdroid/view/ListNodesWithAddButtonView.java new file mode 100644 index 000000000..ddf36df73 --- /dev/null +++ b/app/src/main/java/com/keepassdroid/view/ListNodesWithAddButtonView.java @@ -0,0 +1,322 @@ +/* + * Copyright 2017 Brian Pellin, 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.content.Context; +import android.graphics.Rect; +import android.support.design.widget.FloatingActionButton; +import android.support.v4.view.ViewCompat; +import android.support.v4.view.ViewPropertyAnimatorListener; +import android.support.v4.view.animation.FastOutSlowInInterpolator; +import android.support.v7.widget.RecyclerView; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.Interpolator; +import android.widget.RelativeLayout; + +import com.kunzisoft.keepass.R; + +public class ListNodesWithAddButtonView extends RelativeLayout { + + private enum State { + OPEN, CLOSE + } + + private FloatingActionButton addButton; + private View addEntry; + private View addGroup; + + private boolean addEntryEnable; + private boolean addGroupEnable; + + private State state; + private boolean allowAction; + private OnClickListener onAddButtonClickListener; + private FloatingActionButton.OnVisibilityChangedListener onAddButtonVisibilityChangedListener; + private AddButtonAnimation viewButtonMenuAnimation; + private ViewMenuAnimation viewMenuAnimationAddEntry; + private ViewMenuAnimation viewMenuAnimationAddGroup; + private long animationDuration; + + public ListNodesWithAddButtonView(Context context) { + this(context, null); + } + + public ListNodesWithAddButtonView(Context context, AttributeSet attrs) { + super(context, attrs); + inflate(context); + } + + protected void inflate(Context context) { + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + assert inflater != null; + inflater.inflate(R.layout.list_nodes_with_add_button, this); + + addEntryEnable = true; + addGroupEnable = true; + + addButton = (FloatingActionButton) findViewById(R.id.add_button); + addEntry = findViewById(R.id.add_entry); + addGroup = findViewById(R.id.add_group); + + animationDuration = 300L; + + viewButtonMenuAnimation = new AddButtonAnimation(addButton); + viewMenuAnimationAddEntry = new ViewMenuAnimation(addEntry, 0L, 150L); + viewMenuAnimationAddGroup = new ViewMenuAnimation(addGroup, 150L, 0L); + + allowAction = true; + state = State.CLOSE; + + onAddButtonClickListener = new OnClickListener() { + @Override + public void onClick(View v) { + if (allowAction && state.equals(State.CLOSE)) { + startGlobalAnimation(); + } + } + }; + addButton.setOnClickListener(onAddButtonClickListener); + + onAddButtonVisibilityChangedListener = new FloatingActionButton.OnVisibilityChangedListener() { + @Override + public void onHidden(FloatingActionButton fab) { + super.onHidden(fab); + addButton.setOnClickListener(null); + addButton.setClickable(false); + } + @Override + public void onShown(FloatingActionButton fab) { + super.onShown(fab); + addButton.setOnClickListener(onAddButtonClickListener); + } + }; + + // Hide when scroll + RecyclerView recyclerView = (RecyclerView) findViewById(R.id.nodes_list); + recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + if (state.equals(State.CLOSE)) { + if (dy > 0 && addButton.getVisibility() == View.VISIBLE) { + hideButton(); + } else if (dy < 0 && addButton.getVisibility() != View.VISIBLE) { + showButton(); + } + } + } + }); + } + + public void showButton() { + addButton.show(onAddButtonVisibilityChangedListener); + } + + public void hideButton() { + addButton.hide(onAddButtonVisibilityChangedListener); + } + + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + Rect viewRectG = new Rect(); + getGlobalVisibleRect(viewRectG); + if (viewRectG.contains((int) ev.getRawX(), (int) ev.getRawY())) { + if(allowAction && state.equals(State.OPEN)) { + startGlobalAnimation(); + } + } + return super.dispatchTouchEvent(ev); + } + + /** + * Enable or not the possibility to add an entry by pressing a button + * @param enable true to enable + */ + public void enableAddEntry(boolean enable) { + this.addEntryEnable = enable; + if (enable && addEntry != null && addEntry.getVisibility() != VISIBLE) + addEntry.setVisibility(INVISIBLE); + } + + /** + * Enable or not the possibility to add a group by pressing a button + * @param enable true to enable + */ + public void enableAddGroup(boolean enable) { + this.addGroupEnable = enable; + if (enable && addGroup != null && addGroup.getVisibility() != VISIBLE) + addGroup.setVisibility(INVISIBLE); + } + + public void setAddGroupClickListener(OnClickListener onClickListener) { + if (addEntryEnable) + addGroup.setOnClickListener(onClickListener); + } + + public void setAddEntryClickListener(OnClickListener onClickListener) { + if (addGroupEnable) + addEntry.setOnClickListener(onClickListener); + } + + private void startGlobalAnimation() { + viewButtonMenuAnimation.startAnimation(); + + if (addEntryEnable) { + viewMenuAnimationAddEntry.startAnimation(); + } + if (addGroupEnable) { + viewMenuAnimationAddGroup.startAnimation(); + } + } + + private class AddButtonAnimation implements ViewPropertyAnimatorListener { + + private View view; + private boolean isRotate; + + private Interpolator interpolator; + + AddButtonAnimation(View view) { + this.view = view; + this.isRotate = false; + interpolator = new AccelerateDecelerateInterpolator(); + } + + @Override + public void onAnimationStart(View view) { + allowAction = false; + } + + @Override + public void onAnimationEnd(View view) { + allowAction = true; + isRotate = !isRotate; + if (isRotate) + state = State.OPEN; + else + state = State.CLOSE; + } + + @Override + public void onAnimationCancel(View view) {} + + void startAnimation() { + if(!isRotate) { + ViewCompat.animate(view) + .rotation(135.0F) + .withLayer() + .setDuration(animationDuration) + .setInterpolator(interpolator) + .setListener(this) + .start(); + } else { + ViewCompat.animate(view) + .rotation(0.0F) + .withLayer() + .setDuration(animationDuration) + .setInterpolator(interpolator) + .setListener(this) + .start(); + } + } + } + + private class ViewMenuAnimation implements ViewPropertyAnimatorListener { + + private View view; + private Interpolator interpolator; + private float translation; + private boolean wasInvisible; + private long delayIn; + private long delayOut; + + ViewMenuAnimation(View view, long delayIn, long delayOut) { + this.view = view; + this.interpolator = new FastOutSlowInInterpolator(); + this.wasInvisible = true; + this.translation = 0; + this.delayIn = delayIn; + this.delayOut = delayOut; + } + + ViewMenuAnimation(View view) { + this(view, 0, 0); + } + + @Override + public void onAnimationStart(View view) {} + + @Override + public void onAnimationEnd(View view) { + if(wasInvisible) { + view.setVisibility(VISIBLE); + } else { + view.setVisibility(INVISIBLE); + } + } + + @Override + public void onAnimationCancel(View view) {} + + void startAnimation() { + if(view.getVisibility() == VISIBLE) { + // In + wasInvisible = false; + ViewCompat.animate(view) + .translationY(-translation) + .translationX(view.getWidth()/3) + .alpha(0.0F) + .scaleX(0.33F) + .setDuration(animationDuration-delayIn) + .setInterpolator(interpolator) + .setListener(this) + .setStartDelay(delayIn) + .start(); + } else { + // The first time + if (translation == 0) { + translation = view.getY() + view.getHeight()/2 - addButton.getY() - addButton.getHeight()/2; + view.setTranslationY(-translation); + view.setTranslationX(view.getWidth()/3); + view.setAlpha(0.0F); + view.setScaleX(0.33F); + } + + // Out + view.setVisibility(VISIBLE); + wasInvisible = true; + ViewCompat.animate(view) + .translationY(1) + .translationX(1) + .alpha(1.0F) + .scaleX(1) + .setDuration(animationDuration-delayOut) + .setInterpolator(interpolator) + .setListener(this) + .setStartDelay(delayOut) + .start(); + } + } + } +} diff --git a/app/src/main/java/com/keepassdroid/view/PwEntryView.java b/app/src/main/java/com/keepassdroid/view/PwEntryView.java deleted file mode 100644 index 544449ac6..000000000 --- a/app/src/main/java/com/keepassdroid/view/PwEntryView.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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.os.Handler; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.ImageView; -import android.widget.TextView; - -import com.kunzisoft.keepass.R; -import com.keepassdroid.EntryActivity; -import com.keepassdroid.GroupBaseActivity; -import com.keepassdroid.ProgressTask; -import com.keepassdroid.app.App; -import com.keepassdroid.database.PwEntry; -import com.keepassdroid.database.edit.DeleteEntry; -import com.keepassdroid.settings.PreferencesUtil; - -public class PwEntryView extends ClickView { - - protected GroupBaseActivity mAct; - protected PwEntry mPw; - private TextView mTv; - private int mPos; - - protected static final int MENU_OPEN = Menu.FIRST; - private static final int MENU_DELETE = MENU_OPEN + 1; - - public static PwEntryView getInstance(GroupBaseActivity act, PwEntry pw, int pos) { - return new PwEntryView(act, pw, pos); - } - - protected PwEntryView(GroupBaseActivity act, PwEntry pw, int pos) { - super(act); - mAct = act; - - View ev = View.inflate(mAct, R.layout.list_entries_entry, null); - mTv = (TextView) ev.findViewById(R.id.entry_text); - mTv.setTextSize(PreferencesUtil.getListTextSize(act)); - - populateView(ev, pw, pos); - - LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); - - addView(ev, lp); - - } - - private void populateView(View ev, PwEntry pw, int pos) { - mPw = pw; - mPos = pos; - - ImageView iv = (ImageView) ev.findViewById(R.id.entry_icon); - App.getDB().drawFactory.assignDrawableTo(iv, getResources(), pw.getIcon()); - - mTv.setText(mPw.getDisplayTitle()); - } - - public void convertView(PwEntry pw, int pos) { - populateView(this, pw, pos); - } - - public void refreshTitle() { - mTv.setText(mPw.getDisplayTitle()); - } - - public void onClick() { - launchEntry(); - } - - private void launchEntry() { - EntryActivity.Launch(mAct, mPw, mPos); - - } - - private void deleteEntry() { - Handler handler = new Handler(); - DeleteEntry task = new DeleteEntry(mAct, App.getDB(), mPw, mAct.new RefreshTask(handler)); - ProgressTask pt = new ProgressTask(mAct, task, R.string.saving_database); - pt.run(); - - } - - @Override - public void onCreateMenu(ContextMenu menu, ContextMenuInfo menuInfo) { - menu.add(0, MENU_OPEN, 0, R.string.menu_open); - if (!readOnly) { - menu.add(0, MENU_DELETE, 0, R.string.menu_delete); - } - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - switch ( item.getItemId() ) { - - case MENU_OPEN: - launchEntry(); - return true; - case MENU_DELETE: - deleteEntry(); - return true; - - default: - return false; - } - } - - -} diff --git a/app/src/main/java/com/keepassdroid/view/PwGroupView.java b/app/src/main/java/com/keepassdroid/view/PwGroupView.java deleted file mode 100644 index 7006214c5..000000000 --- a/app/src/main/java/com/keepassdroid/view/PwGroupView.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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.view.ContextMenu; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ContextMenu.ContextMenuInfo; -import android.widget.ImageView; -import android.widget.TextView; - -import com.kunzisoft.keepass.R; -import com.keepassdroid.GroupActivity; -import com.keepassdroid.GroupBaseActivity; -import com.keepassdroid.app.App; -import com.keepassdroid.database.PwGroup; -import com.keepassdroid.database.PwGroupV3; -import com.keepassdroid.settings.PreferencesUtil; - - -public class PwGroupView extends ClickView { - - protected PwGroup mPw; - protected GroupBaseActivity mAct; - protected TextView mTv; - - protected static final int MENU_OPEN = Menu.FIRST; - - public static PwGroupView getInstance(GroupBaseActivity act, PwGroup pw) { - if ( pw instanceof PwGroupV3 ) { - return new PwGroupViewV3(act, pw); - } else { - return new PwGroupView(act, pw); - } - } - - protected PwGroupView(GroupBaseActivity act, PwGroup pw) { - super(act); - mAct = act; - - View gv = View.inflate(act, R.layout.list_entries_group, null); - - mTv = (TextView) gv.findViewById(R.id.group_text); - float size = PreferencesUtil.getListTextSize(act); - mTv.setTextSize(size); - - TextView label = (TextView) gv.findViewById(R.id.group_label); - label.setTextSize(size-8); - - populateView(gv, pw); - - LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); - - addView(gv, lp); - } - - private void populateView(View gv, PwGroup pw) { - mPw = pw; - - ImageView iv = (ImageView) gv.findViewById(R.id.group_icon); - App.getDB().drawFactory.assignDrawableTo(iv, getResources(), pw.getIcon()); - - mTv.setText(pw.getName()); - } - - public void convertView(PwGroup pw) { - populateView(this, pw); - } - - public void onClick() { - launchGroup(); - } - - private void launchGroup() { - GroupActivity.Launch(mAct, mPw); - } - - @Override - public void onCreateMenu(ContextMenu menu, ContextMenuInfo menuInfo) { - menu.add(0, MENU_OPEN, 0, R.string.menu_open); - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - switch ( item.getItemId() ) { - - case MENU_OPEN: - launchGroup(); - return true; - - default: - return false; - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/keepassdroid/view/PwGroupViewV3.java b/app/src/main/java/com/keepassdroid/view/PwGroupViewV3.java deleted file mode 100644 index 0797d419c..000000000 --- a/app/src/main/java/com/keepassdroid/view/PwGroupViewV3.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, 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.os.Handler; -import android.view.ContextMenu; -import android.view.MenuItem; -import android.view.ContextMenu.ContextMenuInfo; - -import com.kunzisoft.keepass.R; -import com.keepassdroid.GroupBaseActivity; -import com.keepassdroid.ProgressTask; -import com.keepassdroid.app.App; -import com.keepassdroid.database.PwGroup; -import com.keepassdroid.database.edit.DeleteGroup; - -public class PwGroupViewV3 extends PwGroupView { - - private static final int MENU_DELETE = MENU_OPEN + 1; - - protected PwGroupViewV3(GroupBaseActivity act, PwGroup pw) { - super(act, pw); - } - - @Override - public void onCreateMenu(ContextMenu menu, ContextMenuInfo menuInfo) { - super.onCreateMenu(menu, menuInfo); - - if (!readOnly) { - menu.add(0, MENU_DELETE, 0, R.string.menu_delete); - } - - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - if ( ! super.onContextItemSelected(item) ) { - switch ( item.getItemId() ) { - case MENU_DELETE: - Handler handler = new Handler(); - DeleteGroup task = new DeleteGroup(App.getDB(), mPw, mAct, mAct.new AfterDeleteGroup(handler)); - ProgressTask pt = new ProgressTask(mAct, task, R.string.saving_database); - pt.run(); - return true; - } - - } - - return false; - } - -} diff --git a/app/src/main/java/com/kunzisoft/keepass/KeePass.java b/app/src/main/java/com/kunzisoft/keepass/KeePass.java index 92ee0addb..8d9ce44b0 100644 --- a/app/src/main/java/com/kunzisoft/keepass/KeePass.java +++ b/app/src/main/java/com/kunzisoft/keepass/KeePass.java @@ -29,8 +29,6 @@ public class KeePass extends Activity { public static final int EXIT_NORMAL = 0; public static final int EXIT_LOCK = 1; - public static final int EXIT_REFRESH = 2; - public static final int EXIT_REFRESH_TITLE = 3; @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/res/drawable/ic_content_copy_black_24dp.xml b/app/src/main/res/drawable/ic_content_copy_black_24dp.xml new file mode 100644 index 000000000..8a894a3bc --- /dev/null +++ b/app/src/main/res/drawable/ic_content_copy_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_remove_circle_white_24dp.xml b/app/src/main/res/drawable/ic_remove_circle_white_24dp.xml new file mode 100644 index 000000000..2e7ac1e2c --- /dev/null +++ b/app/src/main/res/drawable/ic_remove_circle_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout-v23/fingerprint_show.xml b/app/src/main/res/layout-v23/fingerprint_show.xml index d03793359..66a23a421 100644 --- a/app/src/main/res/layout-v23/fingerprint_show.xml +++ b/app/src/main/res/layout-v23/fingerprint_show.xml @@ -4,6 +4,7 @@ android:id="@+id/fingerprint_container" android:layout_width="match_parent" android:layout_height="wrap_content" + android:padding="@dimen/default_margin" tools:visibility="gone"> + style="@style/KeepassDXStyle.TextAppearance.DefaultTextOnPrimary" + android:gravity="center_vertical|end" /> diff --git a/app/src/main/res/layout/entry_edit.xml b/app/src/main/res/layout/entry_edit.xml index 284720a30..b28949e4d 100644 --- a/app/src/main/res/layout/entry_edit.xml +++ b/app/src/main/res/layout/entry_edit.xml @@ -84,20 +84,6 @@ android:hint="@string/entry_user_name" /> - - - - - - + + + + + + - \ No newline at end of file diff --git a/app/src/main/res/layout/entry_edit_section.xml b/app/src/main/res/layout/entry_edit_new_field.xml similarity index 70% rename from app/src/main/res/layout/entry_edit_section.xml rename to app/src/main/res/layout/entry_edit_new_field.xml index d972aa918..0050f8a1e 100644 --- a/app/src/main/res/layout/entry_edit_section.xml +++ b/app/src/main/res/layout/entry_edit_new_field.xml @@ -17,57 +17,59 @@ You should have received a copy of the GNU General Public License along with KeePass DX. If not, see . --> - - - - - + android:layout_height="match_parent" + android:paddingTop="12dp" + android:paddingBottom="12dp"> + android:layout_toLeftOf="@+id/entry_edit_new_field_delete" + android:layout_toStartOf="@+id/entry_edit_new_field_delete"> - + android:maxLines="1" /> + + + + - - \ No newline at end of file + diff --git a/app/src/main/res/layout/entry_new_field.xml b/app/src/main/res/layout/entry_new_field.xml new file mode 100644 index 000000000..723e5b251 --- /dev/null +++ b/app/src/main/res/layout/entry_new_field.xml @@ -0,0 +1,46 @@ + + + + + + + + diff --git a/app/src/main/res/layout/entry_view.xml b/app/src/main/res/layout/entry_view.xml index c1efbb1d9..a2b655271 100644 --- a/app/src/main/res/layout/entry_view.xml +++ b/app/src/main/res/layout/entry_view.xml @@ -19,7 +19,8 @@ --> + android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto"> \ No newline at end of file diff --git a/app/src/main/res/layout/entry_view_contents.xml b/app/src/main/res/layout/entry_view_contents.xml index b57d36fa3..e697cc96a 100644 --- a/app/src/main/res/layout/entry_view_contents.xml +++ b/app/src/main/res/layout/entry_view_contents.xml @@ -23,56 +23,110 @@ android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="vertical"> - - - - - - + + + + + + - - + + + + + + + + + + + - - + + + + + + app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> + android:layout_height="match_parent" /> @@ -112,5 +110,6 @@ android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:src="@drawable/ic_database_plus_white_24dp" + app:useCompatPadding="true" style="@style/KeepassDXStyle.Fab"/> \ 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 2dcb5fb71..5bb5ae1cd 100644 --- a/app/src/main/res/layout/file_selection_filename.xml +++ b/app/src/main/res/layout/file_selection_filename.xml @@ -48,17 +48,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/KeepassDXStyle.TextAppearance.Inverse" - android:text="@string/enter_filename"/> + android:text="@string/select_database_file"/> @@ -69,8 +68,12 @@ android:layout_below="@id/label_open_by_filename" android:inputType="textUri" android:textColor="?attr/textColorInverse" - android:layout_toLeftOf="@+id/browse_button" - android:layout_toStartOf="@+id/browse_button" + android:layout_marginStart="2dp" + android:layout_marginLeft="2dp" + android:layout_marginRight="2dp" + android:layout_marginEnd="2dp" + android:layout_toRightOf="@+id/browse_button" + android:layout_toEndOf="@+id/browse_button" android:maxLines="1" /> diff --git a/app/src/main/res/layout/group_add_entry.xml b/app/src/main/res/layout/group_add_entry.xml deleted file mode 100644 index 94e7e06d4..000000000 --- a/app/src/main/res/layout/group_add_entry.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/group_empty.xml b/app/src/main/res/layout/list_nodes.xml similarity index 59% rename from app/src/main/res/layout/group_empty.xml rename to app/src/main/res/layout/list_nodes.xml index 7c47d3d95..4cbe9e661 100644 --- a/app/src/main/res/layout/group_empty.xml +++ b/app/src/main/res/layout/list_nodes.xml @@ -18,19 +18,15 @@ along with KeePass DX. If not, see . --> - - - + android:layout_width="match_parent" + android:layout_height="match_parent"> + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/list_entries_entry.xml b/app/src/main/res/layout/list_nodes_entry.xml similarity index 91% rename from app/src/main/res/layout/list_entries_entry.xml rename to app/src/main/res/layout/list_nodes_entry.xml index 0b8913078..df85a7509 100644 --- a/app/src/main/res/layout/list_entries_entry.xml +++ b/app/src/main/res/layout/list_nodes_entry.xml @@ -18,9 +18,11 @@ along with KeePass DX. If not, see . --> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:background="?android:attr/selectableItemBackground" > . --> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:background="?android:attr/selectableItemBackground" > + android:layout_toRightOf="@+id/group_arrow" + android:layout_toEndOf="@+id/group_arrow" /> - - \ No newline at end of file diff --git a/app/src/main/res/layout/list_nodes_with_add_button.xml b/app/src/main/res/layout/list_nodes_with_add_button.xml new file mode 100644 index 000000000..5bc435daf --- /dev/null +++ b/app/src/main/res/layout/list_nodes_with_add_button.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/password.xml b/app/src/main/res/layout/password.xml index 63d59c1e0..b5220a731 100644 --- a/app/src/main/res/layout/password.xml +++ b/app/src/main/res/layout/password.xml @@ -22,147 +22,173 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/container" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingBottom="@dimen/default_margin" - android:clipToPadding="false"> + android:layout_height="match_parent"> - + android:layout_height="match_parent"> - - + android:fitsSystemWindows="true"> - + - - - - - - - - - - - - + android:layout_height="match_parent" + android:layout_marginTop="?attr/actionBarSize"> + + - + - - + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:ellipsize="marquee" + android:focusable="true" + android:focusableInTouchMode="true" + android:marqueeRepeatLimit="marquee_forever" + android:scrollHorizontally="true" + android:singleLine="true" /> + - - + + - + - - - - - - - - - + android:padding="@dimen/default_margin"> - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/lock_database.xml b/app/src/main/res/menu/database_lock.xml similarity index 96% rename from app/src/main/res/menu/lock_database.xml rename to app/src/main/res/menu/database_lock.xml index c6c153db8..b44bea3e9 100644 --- a/app/src/main/res/menu/lock_database.xml +++ b/app/src/main/res/menu/database_lock.xml @@ -22,5 +22,6 @@ \ No newline at end of file diff --git a/app/src/main/res/menu/database.xml b/app/src/main/res/menu/database_master_key.xml similarity index 86% rename from app/src/main/res/menu/database.xml rename to app/src/main/res/menu/database_master_key.xml index e13e3eeba..5e0e640e9 100644 --- a/app/src/main/res/menu/database.xml +++ b/app/src/main/res/menu/database_master_key.xml @@ -19,12 +19,9 @@ --> - \ No newline at end of file diff --git a/app/src/main/res/menu/default_menu.xml b/app/src/main/res/menu/default_menu.xml index 17fa82614..1d612796b 100644 --- a/app/src/main/res/menu/default_menu.xml +++ b/app/src/main/res/menu/default_menu.xml @@ -22,9 +22,11 @@ diff --git a/app/src/main/res/menu/donation.xml b/app/src/main/res/menu/donation.xml index 716caaeda..d0a2c84d4 100644 --- a/app/src/main/res/menu/donation.xml +++ b/app/src/main/res/menu/donation.xml @@ -22,5 +22,6 @@ \ No newline at end of file diff --git a/app/src/main/res/menu/entry.xml b/app/src/main/res/menu/entry.xml index 8f8134b23..33c4266d3 100644 --- a/app/src/main/res/menu/entry.xml +++ b/app/src/main/res/menu/entry.xml @@ -22,15 +22,11 @@ - - diff --git a/app/src/main/res/layout/entry_section.xml b/app/src/main/res/menu/fingerprint.xml similarity index 51% rename from app/src/main/res/layout/entry_section.xml rename to app/src/main/res/menu/fingerprint.xml index b3c87d78e..34606fb2b 100644 --- a/app/src/main/res/layout/entry_section.xml +++ b/app/src/main/res/menu/fingerprint.xml @@ -1,7 +1,7 @@ - - - - + + + \ No newline at end of file diff --git a/app/src/main/res/menu/search.xml b/app/src/main/res/menu/search.xml index e2fa9dc4c..b157ed1e0 100644 --- a/app/src/main/res/menu/search.xml +++ b/app/src/main/res/menu/search.xml @@ -23,5 +23,6 @@ android:icon="@drawable/ic_search_white_24dp" android:title="@string/menu_search" app:showAsAction="always|collapseActionView" + android:orderInCategory="31" app:actionViewClass="android.support.v7.widget.SearchView" /> \ No newline at end of file diff --git a/app/src/main/res/menu/tree.xml b/app/src/main/res/menu/tree.xml index fbbbc283d..1aabbf1a0 100644 --- a/app/src/main/res/menu/tree.xml +++ b/app/src/main/res/menu/tree.xml @@ -21,6 +21,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index 66d1b7e68..0f3305780 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -51,23 +51,23 @@ Desencriptant entrada Utilitza aquesta com a base de dades per defecte Dígits - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin ve SENSE CAP MENA DE GARANTIA; Això és programari lliure, i pots redistribuïr-lo sota els termes de la llicència GPL versió 2 o posterior. + KeePass DX \u00A9 %1$d Kunzisoft ve SENSE CAP MENA DE GARANTIA; Això és programari lliure, i pots redistribuïr-lo sota els termes de la llicència GPL versió 2 o posterior. \u2026 - Introdueix el nom de la base de dades: - Accedida: + Introdueix el nom de la base de dades: + Accedida Introdueix una contrasenya i/o un arxiu clau per desbloquejar la base de dades: Cancel·la - Comentaris: - Confirma contrasenya: - Creada: - Expira: + Comentaris + Confirma contrasenya + Creada + Expira Arxiu clau - Modificada: - Contrasenya: + Modificada + Contrasenya Guarda - Nom: - URL: - Usuari: + Nom + URL + Usuari L\'encriptació ArcFour no està suportada. KeePass DX no pot manejar aquesta uri. Error creant grup. @@ -171,9 +171,13 @@ Versió: + 5 segons + 10 segons + 20 segons 30 segons 1 minut 5 minuts + 15 minuts Mai diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 579958585..8330ea3be 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -56,24 +56,24 @@ Dešifruji záznam Použít jako výchozí databázi Čísla - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin dodáván BEZ JAKÉKOLIV ZÁRUKY; Toto je free software zdarma, a je možná jeho redistribuce pod podmínkou licence GPL verze 2 nebo novější. + KeePass DX \u00A9 %1$d Kunzisoft dodáván BEZ JAKÉKOLIV ZÁRUKY; Toto je free software zdarma, a je možná jeho redistribuce pod podmínkou licence GPL verze 2 nebo novější. \u2026 - Zadejte názvev souboru databáze: - Poslední přístup: + Zadejte názvev souboru databáze: + Poslední přístup Zadejte heslo a/nebo soubor s klíčem pro odemknutí databáze: Storno - Poznámky: - Potvrďte heslo: - Vytvořeno: - Vyprší: + Poznámky + Potvrďte heslo + Vytvořeno + Vyprší Klíčový soubor - Změněno: + Změněno Vstupní data nenalezena. - Heslo: + Heslo Uložit - Název: - URL: - Uživatelské jméno: + Název + URL + Uživatelské jméno ArcFour stream šifra není podporována. KeePass DX nemůže zpracovat tuto uri. Chyba při vytváření skupiny. @@ -188,9 +188,13 @@ Verze: + 5 sekund + 10 sekund + 20 sekund 30 sekund 1 minuta 5 minut + 15 minut Nikdy diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index c6d17d145..f805fae14 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -55,24 +55,24 @@ Dekrypterer post Brug denne database som standard Cifre - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under the conditions of the GPL version 2 or later. + KeePass DX \u00A9 %1$d Kunzisoft comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under the conditions of the GPL version 2 or later. \u2026 - Angiv navn på databasefil: - Senest åbnet: + Angiv navn på databasefil: + Senest åbnet Angiv en adgangskode og/eller en nøglefil for at få adgang til din database: Annuller - Kommentarer: - Bekræft adgangskode: - Oprettet: - Udløber: + Kommentarer + Bekræft adgangskode + Oprettet + Udløber Nøglefil - Ændret: + Ændret Data for posten blev ikke fundet. - Adgangskode: + Adgangskode Gem - Navn: - URL: - Brugernavn: + Navn + URL + Brugernavn "ArcFour stream cipher" er ikke understøttet. KeePass DX kan ikke håndtere denne uri. Fejl ved oprettelse af gruppe. @@ -187,9 +187,13 @@ Version: + 5 sekunder + 10 sekunder + 20 sekunder 30 sekunder 1 minut 5 minutter + 15 minutter Aldrig diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index a5d513c37..c7a31110d 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -59,24 +59,24 @@ Eintrag entschlüsselt Als Standard-Datenbank benutzen Zahlen - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin. Alle Rechte vorbehalten. Die Nutzung der Software erfolgt auf eigene Verantwortung und ohne jegliche Garantie. Die Applikation ist kostenlos und wird unter den Bedingungen der GNU GPL Version 2 (oder später) verbreitet und lizenziert. + KeePass DX \u00A9 %1$d Kunzisoft. Alle Rechte vorbehalten. Die Nutzung der Software erfolgt auf eigene Verantwortung und ohne jegliche Garantie. Die Applikation ist kostenlos und wird unter den Bedingungen der GNU GPL Version 2 (oder später) verbreitet und lizenziert. \u2026 - Dateinamen der Datenbank eingeben: - Letzter Zugriff: + Dateinamen der Datenbank eingeben: + Letzter Zugriff Passwort und/oder Schlüsseldatei zum Entschlüsseln Ihrer Datenbank eingeben: Abbrechen - Kommentare: - Passwort wiederholen: - Erstelldatum: - Ablaufdatum: + Kommentare + Passwort wiederholen + Erstelldatum + Ablaufdatum Schlüsseldatei - Änderungsdatum: + Änderungsdatum Eintrag wurde nicht gefunden. - Passwort: + Passwort Speichern - Titel: - URL: - Benutzername: + Titel + URL + Benutzername Die RC4/ARC4-Stromverschlüsselung wird nicht unterstützt. KeePass DX kann diese URI-Adresse nicht verarbeiten. Fehler beim Erstellen der Gruppe. @@ -200,9 +200,13 @@ Version: + 5 Sekunden + 10 Sekunden + 20 Sekunden 30 Sekunden 1 Minute 5 Minuten + 15 Minuten Nie diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 39a339ec3..2bd14b81c 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -53,24 +53,24 @@ Αποκρυπτογράφηση εγγραφής Χρήση αυτής της βάσης ως προεπιλεγμένη Ψηφία - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin χωρίς ΚΑΜΙΑ ΑΠΟΛΥΤΩΣ ΕΓΓΥΗΣΗ. Το παρόν είναι δωρεάν λογισμικό και είστε ευπρόσδεκτοι να το διαμοιράσετε υπό τις συνθήκες της ΙΕΛ έκδοσης 2 ή μεταγενέστερης. + KeePass DX \u00A9 %1$d Kunzisoft χωρίς ΚΑΜΙΑ ΑΠΟΛΥΤΩΣ ΕΓΓΥΗΣΗ. Το παρόν είναι δωρεάν λογισμικό και είστε ευπρόσδεκτοι να το διαμοιράσετε υπό τις συνθήκες της ΙΕΛ έκδοσης 2 ή μεταγενέστερης. \u2026 - Εισαγωγή ονόματος βάσης δεδομένων: - Προσπελάσθηκε: + Εισαγωγή ονόματος βάσης δεδομένων: + Προσπελάσθηκε Εισάγετε έναν κωδικό πρόσβασης και/ή αρχείο κλειδιού για να ξεκλειδώσετε τη βάση δεδομένων σας: Ακύρωση - Σχόλια: - Επιβεβαίωση κωδικού πρόσβασης: - Δημιουργήθηκε: - Λήγει: + Σχόλια + Επιβεβαίωση κωδικού πρόσβασης + Δημιουργήθηκε + Λήγει Αρχείο Κλειδιού - Τροποποιήθηκε: + Τροποποιήθηκε Δεν βρέθηκαν δεδομένα εγγραφών. - Κωδικός Πρόσβασης: + Κωδικός Πρόσβασης Αποθήκευση - Όνομα: - Διεύθυνση URL: - Όνομα Χρήστη: + Όνομα + Διεύθυνση URL + Όνομα Χρήστη Η ροή κρυπτογράφησης ArcFour δεν υποστηρίζεται. Το KeePass DX δε μπορεί να χειριστεί αυτή τη διεύθυνση uri. Σφάλμα κατά τη δημιουργία της ομάδας. @@ -185,9 +185,13 @@ Έκδοση: + 5 δευτερόλεπτα + 10 δευτερόλεπτα + 20 δευτερόλεπτα 30 δευτερόλεπτα 1 λεπτό 5 λεπτά + 15 λεπτά Ποτέ diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index d85b9c648..96b9da03f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -50,23 +50,23 @@ Spanish translation by José I. Paños. Updated by David García-Abad (23-09-201 Descrifrando la entrada Utilice esto como base de datos por defecto Dígitos - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin NO TIENE TOTAL GARANTÍA; Este es software libre, y puedes redristribuirlo bajo las condiciones de la licencia GPL version 2 o posterior. + KeePass DX \u00A9 %1$d Kunzisoft NO TIENE TOTAL GARANTÍA; Este es software libre, y puedes redristribuirlo bajo las condiciones de la licencia GPL version 2 o posterior. \u2026 - Introduzca el nombre del archivo de base de datos: - Acceso: + Introduzca el nombre del archivo de base de datos: + Acceso Introduzca una contraseña y/o un archivo de clave para desbloquear su base de datos: Cancelar - Comentario: - Confirmar contraseña: - Creación: - Caducidad: + Comentario + Confirmar contraseña + Creación + Caducidad Archivo de clave - Modificación: - Contraseña: + Modificación + Contraseña Guardar - Nombre: - URL: - Nombre de usuario: + Nombre + URL + Nombre de usuario Secuencia de cifrado ArcFour no soportada. KeePass DX no puede manejar este uri. Error creando grupo. @@ -171,9 +171,13 @@ Spanish translation by José I. Paños. Updated by David García-Abad (23-09-201 Versión: + 5 segundos + 10 segundos + 20 segundos 30 segundos 1 minuto 5 minutos + 15 minutos Nunca diff --git a/app/src/main/res/values-eu/strings.xml b/app/src/main/res/values-eu/strings.xml index 7b042a156..196ef3307 100644 --- a/app/src/main/res/values-eu/strings.xml +++ b/app/src/main/res/values-eu/strings.xml @@ -55,24 +55,24 @@ Sarrera desenkriptatzen Hau erabili modu lehenetsitako datubase gisa Zenbakiak - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin ez dakar inolako bermerik; Lan hau software librea da; banatu edo/eta aldatu egin dezakezu GNU General Public License bigarren bertsioaren baldintzapean. + KeePass DX \u00A9 %1$d Kunzisoft ez dakar inolako bermerik; Lan hau software librea da; banatu edo/eta aldatu egin dezakezu GNU General Public License bigarren bertsioaren baldintzapean. \u2026 - Datubasearen fitxategiaren izena sartu: - Akzesoa: + Datubasearen fitxategiaren izena sartu: + Akzesoa Sartu pasahitz eta / edo gako fitxategi bat zure datubasea desblokeatzeko: Utzi - Iruzkinak: - Pasahitza berretsi: - Sortua: - Iraungitzen da: + Iruzkinak + Pasahitza berretsi + Sortua + Iraungitzen da Gako fitxategia - Aldatua: + Aldatua Sarreraren datuak ez aurkituak. - Pasahitza: + Pasahitza Gorde - Izena: - URLa: - Erabiltzaile izena: + Izena + URLa + Erabiltzaile izena ArcFour stream zifratze sisterako ez dago euskarririk.. KeePass DX-ek ezin dut uri hau kudeatu. Errorea taldea sortzerakoan. @@ -185,9 +185,13 @@ Bertsioa: + 5 segundu + 10 segundu + 20 segundu 30 segundu minutu 1 5 minutu + 15 minutu Inoiz ez diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index ba7ba4638..7d448c824 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -53,24 +53,24 @@ Puretaan salasanatietuetta Käytä tätä oletustietokantana Numerot - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under the conditions of the GPL version 2 or later. + KeePass DX \u00A9 %1$d Kunzisoft comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under the conditions of the GPL version 2 or later. \u2026 - Anna tietokannan tiedostonimi: - Käytetty: + Anna tietokannan tiedostonimi: + Käytetty Syötä salasana ja/tai avaintiedosto avataksesi tietokantasi: Peruuta - Kommentit: - Vahvista salasana: - Luotu: - Vanhenee: + Kommentit + Vahvista salasana + Luotu + Vanhenee Avaintiedosto - Muokattu: + Muokattu Tietueen tietoja ei löytynyt. - Salasana: + Salasana Tallenna - Nimi: - URL-osoite: - Käyttäjänimi: + Nimi + URL-osoite + Käyttäjänimi The ArcFour stream cipher ei ole tuettu. KeePass DX ei osaa käsitellä tätä osoitetta. Virhe ryhmän luonnissa. @@ -183,9 +183,13 @@ Versio: + 5 sekuntia + 10 sekuntia + 20 sekuntia 30 sekuntia 1 minuutti 5 minuttia + 15 minuttia Ei koskaan diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index b9e2eeb9a..cafde3405 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -40,6 +40,7 @@ File browsing requires the Open Intents File Manager, click below to install it. Due to some quirks in the file manager, browsing may not work correctly, the first time you browse. Reconstruction de l\'index de recherche… Annuler + Permettre Presse-papier vidé Erreur de presse-papier Certains appareils Android Samsung ont un bug dans l\'implémentation du presse-papier qui empêche la copie depuis des applications. Pour plus de détails, visitez : @@ -56,9 +57,8 @@ Déchiffrement de l\'entrée Utiliser comme base de données par défaut Nombres - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin n\'offre ABSOLUMENT AUCUNE GARANTIE; il s\'agit d\'un logiciel libre, vous pouvez le redistribuer sous les conditions de la licence GPL v2 ou ultérieure. + KeePass DX \u00A9 %1$d Kunzisoft n\'offre ABSOLUMENT AUCUNE GARANTIE; il s\'agit d\'un logiciel libre, vous pouvez le redistribuer sous les conditions de la licence GPL v2 ou ultérieure. \u2026 - Sélectionnez la base de données : Dernier accès Entrez un mot de passe et/ou un fichier de clé pour ouvrir la base de données : Annuler @@ -71,7 +71,7 @@ Entry data not found. Mot de passe Enregistrer - Nom + Titre URL Nom d\'utilisateur Le chiffrement de flux ArcFour n\'est pas supporté. @@ -130,8 +130,7 @@ Par défaut, masquer le mot de passe À propos Modifier la clé maître - Copier le mot de passe - Copier le nom d\'utilisateur + Copie de %1$s Créer Préférences Préférences de la base de données @@ -145,13 +144,15 @@ Renommer Rechercher Afficher le mot de passe + Supprimer la clé de l\'empreinte Ouvrir l\'URL Moins Jamais Aucun élément. Aucun résultat pour cette recherche. Impossible d\'ouvrir cette URL. - Bases de données utilisées récemment : + Sélectionner une base de données existante : + Ouvrir une base de données récente : Ignorer les sauvegardes Ignorer le groupe Sauvegardes des résultats de recherche (uniquement pour .kdb) Fichier de base de données KeePass @@ -179,8 +180,17 @@ Espace Rechercher Afficher le mot de passe - Tri par nom + Trier + Ascendant + Groupes avant + Corbeille à la fin Tri par défaut (base de données) + Tri par Titre + Tri par nom + Tri par Nom d\'utilisateur + Tri par Date de Création + Tri par Date de Dernière Modification + Tri par Date de Dernier Accès Spécial Nom/description Résultats @@ -239,11 +249,21 @@ Octets Chemin de fichier Afficher le chemin complet des fichiers + Utiliser la corbeille + Déplace un groupe ou une entrée dans la Corbeille avant la suppression + KeePass DX a besoin d\'une permission de stockage externe pour écrire une base de données + KeePass DX a besoin d\'une permission de stockage externe pour lire une URI non fournie par un Content Provider + Permission de stockage externe refusée + Impossible d\'effectuer l\'action sans autorisation de stockage externe + 5 secondes + 10 secondes + 20 secondes 30 secondes 1 minute 5 minutes + 15 minutes Jamais diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index e791df82d..fa4fa6374 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -50,23 +50,23 @@ Bejegyzés dekódolása Adatbázis beállítása alapértelmezettként Számok - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin. Ehhez a programhoz SEMMILYEN GARANCIA NEM JÁR; Ez egy szabad szoftver, GNU General Public License v2 vagy későbbi verziójának feltételei mellett terjeszthető, illetve módosítható. Fordította: Eversmann + KeePass DX \u00A9 %1$d Kunzisoft. Ehhez a programhoz SEMMILYEN GARANCIA NEM JÁR; Ez egy szabad szoftver, GNU General Public License v2 vagy későbbi verziójának feltételei mellett terjeszthető, illetve módosítható. Fordította: Eversmann … - Adja meg az adatbázis fájlnevét: - Utolsó hozzáférés: + Adja meg az adatbázis fájlnevét: + Utolsó hozzáférés Adja meg a jelszót és/vagy a kulcsfájlt, hogy kinyithassa az adatbázist: Mégsem - Megjegyzés: - Jelszó megerősítése: - Létrehozva: - Lejárat: + Megjegyzés + Jelszó megerősítése + Létrehozva + Lejárat Kulcsfájl - Módosítva: - Jelszó: + Módosítva + Jelszó Mentés - Név: - URL: - Felhasználónév: + Név + URL + Felhasználónév Az ArcFour folyamrejtjel nem támogatott. Nem található kezelő ehhez az uri-hoz. Hiba a csoport létrehozásakor. @@ -194,9 +194,13 @@ Nincs még jelszó beállítva ehhez az adatbázishoz + 5 másodperc + 10 másodperc + 20 másodperc 30 másodperc 1 perc 5 perc + 15 perc Soha diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 252d6bf24..8514aaf5d 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -51,23 +51,23 @@ Decodifica valore Usa come database predefinito Cifre - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin viene distribuito ASSOLUTAMENTE con NESSUNA GARANZIA; Si tratta di software libero, e sei invitato a distribuirlo sotto le condizioni della licenza GPL versione 2 o superiore. + KeePass DX \u00A9 %1$d Kunzisoft viene distribuito ASSOLUTAMENTE con NESSUNA GARANZIA; Si tratta di software libero, e sei invitato a distribuirlo sotto le condizioni della licenza GPL versione 2 o superiore. \u2026 - Inserisci il nome file del database: - Ultimo accesso: + Inserisci il nome file del database: + Ultimo accesso Inserisci una password e/o file chiave per sbloccare il database: Annulla - Commento: - Conferma password: - Creato: - Scade: + Commento + Conferma password + Creato + Scade File chiave - Modificato: + Modificato Password Salva - Nome: - URL: - Nome utente: + Nome + URL + Nome utente La codifica ArcFour non è supportata. KeePass DX non può gestire questo URL. Errore creazione gruppo. @@ -170,9 +170,13 @@ Versione: + 5 secondi + 10 secondi + 20 secondi 30 secondi 1 minuto 5 minuti + 15 minuti Mai diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index be39fa7ad..ca5c3f297 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -54,21 +54,21 @@ מפענח חוליה השתמש בזה כמסד הנתונים הברירת מחדל ספרות - הזן שם קובץ למסד נתונים: - ניגש לאחרונה: + הזן שם קובץ למסד נתונים: + ניגש לאחרונה הזן סיסמה ו/או קובץ מפתח כדי לפתוח את מסד הנתונים: בטל - הערות: - אשר סיסמה: - תאריך יצירה: - פג תוקף: + הערות + אשר סיסמה + תאריך יצירה + פג תוקף קובץ מפתח - נערך לאחרונה: + נערך לאחרונה נתוני ערך לא נמצאו. - סיסמה: + סיסמה שמור - שם: - שם משתמש: + שם + שם משתמש צופן זרם ArcFour אינו נתמך. KeePass DX לא יכול לטפל ב-URI הזה. שגיאה ביצירת קבוצה. @@ -177,9 +177,13 @@ כרטיס ה-SD במצב לקריאה בלבד. אתה לא תוכל לשמור או ליצור במסד הנתונים. גרסה: + 5 שניות + 10 שניות + 20 שניות 30 שניות דקה אחת 5 דקות + 15 דקות אף פעם diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 7640eae4e..12aa09449 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -48,23 +48,23 @@ 暗号解除エントリー このデータベースを次回以降も利用する 数字 - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin によって作られたフリーソフトウェアであり、無保証です。GPLバージョン2以上の条件下でこれを再頒布することができます。 + KeePass DX \u00A9 %1$d Kunzisoft によって作られたフリーソフトウェアであり、無保証です。GPLバージョン2以上の条件下でこれを再頒布することができます。 \u2026 - データベースファイル: - 最終アクセス日: + データベースファイル: + 最終アクセス日 データベースに設定したパスワードを入力するかキーファイルを選択してください。 キャンセル - 備考: - パスワードの確認: - 作成日: - 有効期限: + 備考 + パスワードの確認 + 作成日 + 有効期限 キーファイル - 更新日: - パスワード: + 更新日 + パスワード 保存 - タイトル: - URL: - ユーザー名: + タイトル + URL + ユーザー名 ArcFour stream cipherには対応していません。 KeePass DXはこのuriを処理できません。 グループ追加エラー @@ -167,9 +167,13 @@ バージョン: + 5秒 + 10秒 + 20秒 30秒 1分 5分 + 15分 なし diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 31e569d00..508ea358d 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -23,15 +23,15 @@ Duomenų bazė Skaitmenys Atšaukti - Komentarai: - Sukurta: - Keista: - Pasibaigia: - Slaptažodis: + Komentarai + Sukurta + Keista + Pasibaigia + Slaptažodis Išsaugoti - Pavadinimas: - URL: - Naudotojo vardas: + Pavadinimas + URL + Naudotojo vardas Neteisinga duomenų bazė. Lauko pavadinimas Lauko reikšmė @@ -71,7 +71,7 @@ Rūšiuoti pagal pavadinimą Versija: Įspėjimas - Įveskite duomenų bazės failą + Įveskite duomenų bazės failą Įveskite teigiamą skaičių ilgio lauke Naujausių failų istorija Atsiminti paskutinius naudotus failų pavadinimus diff --git a/app/src/main/res/values-lv/strings.xml b/app/src/main/res/values-lv/strings.xml index 379a3003c..98012d1fc 100644 --- a/app/src/main/res/values-lv/strings.xml +++ b/app/src/main/res/values-lv/strings.xml @@ -36,21 +36,21 @@ Izmantot šo kā manu noklusējuma datu bāzi Cipari … - Ievadiet datu bāzes nosaukumu: - Piekļuve: + Ievadiet datu bāzes nosaukumu: + Piekļuve Ievadiet paroli/atslēgas failu, lai atbloķētu savu datu bāzi: Atcelt - Komentāri: - Apstipriniet paroli: - Izveidots: - Derīguma termiņš beidzas: + Komentāri + Apstipriniet paroli + Izveidots + Derīguma termiņš beidzas Atslēgas fails - Modificēts: - Parole: + Modificēts + Parole Saglabāt - Vārds: - URL: - Lietotāja vārds: + Vārds + URL + Lietotāja vārds ArcFour plūsmas šifrs netiek atbalstīts. Neizdevās pātiet uz norādīto adresi. Neizdevās izveidot grupu. @@ -163,9 +163,13 @@ Versija: + 5 sekundes + 10 sekundes + 20 sekundes 30 sekundes 1 minūte 5 minūtes + 15 minūtes Nekad diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index b5af06901..0f051a5a3 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -50,23 +50,23 @@ Record wordt ontcijferd Gebruik dit als mijn standaard database Cijfers - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin biedt GEEN ENKELE GARANTIE; Dit is vrije software, u mag deze software verspreiden onder de voorwaarden van de GPL versie 2 of recenter. + KeePass DX \u00A9 %1$d Kunzisoft biedt GEEN ENKELE GARANTIE; Dit is vrije software, u mag deze software verspreiden onder de voorwaarden van de GPL versie 2 of recenter. \u2026 - Geef de databasebestandsnaam: - Laatst benaderd: + Geef de databasebestandsnaam: + Laatst benaderd Geef het wachtwoord en/of het sleutelbestand om uw database te ontgrendelen: Annuleren - Commentaar: - Bevestig wachtwoord: - Aangemaakt op: - Verloopt op: + Commentaar + Bevestig wachtwoord + Aangemaakt op + Verloopt op Sleutelbestand - Gewijzigd op: - Wachtwoord: + Gewijzigd op + Wachtwoord Opslaan - Naam: - URL: - Gebruikersnaam: + Naam + URL + Gebruikersnaam De ArcFour stream-versleuteling wordt niet ondersteund. KeePass DX kan deze uri niet verwerken. Fout bij het aanmaken van de groep. @@ -169,9 +169,13 @@ Versie: - 30 seconden + 5 seconden + 10 seconden + 20 seconden + 30 seconden 1 minuut 5 minuten + 15 minuten Nooit diff --git a/app/src/main/res/values-nn/strings.xml b/app/src/main/res/values-nn/strings.xml index a5c035db1..692335e13 100644 --- a/app/src/main/res/values-nn/strings.xml +++ b/app/src/main/res/values-nn/strings.xml @@ -48,23 +48,23 @@ Dekrypterer oppføringa Standarddatabasen Tal - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin kjem med INGEN SOM HELST GARANTI. Dette er eit fritt program. Du er velkomen til å redistribuera det i samsvar med vilkåra til GPL utgåve 2 eller nyare. + KeePass DX \u00A9 %1$d Kunzisoft kjem med INGEN SOM HELST GARANTI. Dette er eit fritt program. Du er velkomen til å redistribuera det i samsvar med vilkåra til GPL utgåve 2 eller nyare. \u2026 - Skriv filnamnet til databasen: - Brukt: + Skriv filnamnet til databasen: + Brukt Skriv inn passordet og/eller nøkkelfil for å låsa opp databasen: Avbryt - Merknader: - Stadfest passordet: - Laga: - Går ut: + Merknader + Stadfest passordet + Laga + Går ut Nøkkelfil - Endra: - Passord: + Endra + Passord Lagra - Namn: - Adresse: - Brukaramn: + Namn + Adresse + Brukaramn Kan ikkje bruka ArcFour dataflytkryptering. KeePass DX kan ikkje bruka denne ressursen. Klarte ikkje å laga gruppa. @@ -167,9 +167,13 @@ Utgåve: + 5 sekund + 10 sekund + 20 sekund 30 sekund 1 minutt 5 minutt + 15 minutt Aldri diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 7066f18ad..6dec6207d 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -48,21 +48,21 @@ along with KeePass DX. If not, see . Używaj tej bazy danych jako domyślnej Cyfry \u2026 - Wprowadź nazwę pliku bazy danych: - Dostęp do pliku: + Wprowadź nazwę pliku bazy danych: + Dostęp do pliku Wprowadź hasło i/lub plik klucza by uzyskać dostęp do bazy danych: Anuluj - Komentarz: - Potwierdź hasło: - Utworzono: - Wygasa: + Komentarz + Potwierdź hasło + Utworzono + Wygasa Plik klucza - Zmodyfikowano: + Zmodyfikowano Hasło Zapisz - Tytuł: - URL: - Nazwa użytkownika: + Tytuł + URL + Nazwa użytkownika Strumieniowe szyfrowanie ArcFour nie jest wspierane. KeePass DX nie potrafi obsłużyć tego uri. Błąd podczas tworzenia grupy. @@ -170,9 +170,13 @@ along with KeePass DX. If not, see . Karta SD nie jest obecnie zamontowana w urządzeniu. Możesz nie być w stanie wczytać lub utworzyć bazy danych. + 5 sekund + 10 sekund + 20 sekund 30 sekund 1 minuta 5 minut + 15 minut Nigdy diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index b60a8471f..9952fcda4 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -51,23 +51,23 @@ Decifrando entrada Usar este banco de dados como padrão Digitos - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin vem com ABSOLUTAMENTE NENHUMA GARANTIA; Este é um software livre, e você está convidado a redistribui-lo sob as condições da GPL versão 2 ou posterior. + KeePass DX \u00A9 %1$d Kunzisoft vem com ABSOLUTAMENTE NENHUMA GARANTIA; Este é um software livre, e você está convidado a redistribui-lo sob as condições da GPL versão 2 ou posterior. \u2026 - Digite o nome do arquivo de banco de dados: - Acessado: + Digite o nome do arquivo de banco de dados: + Acessado Digite uma senha e/ ou entre com o caminho para o arquivo de chaves do banco de dados: Cancelar - Comentários: - Confirmar senha: - Criado: - Expira: + Comentários + Confirmar senha + Criado + Expira Arquivo de chave - Modificado: - Senha: + Modificado + Senha Salvar - Nome: - URL: - Nome de usuário: + Nome + URL + Nome de usuário A cifra de fluxo ArcFour não é suportada. KeePass DX não pôde tratar esta uri. Erro ao criar grupo. @@ -170,9 +170,13 @@ Versão: + 5 segundos + 10 segundos + 20 segundos 30 segundos 1 minuto 5 minutos + 15 minutos Nunca diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 36ced6d23..76cc4a32a 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -56,24 +56,24 @@ A desencriptar entrada Utilizar esta base de dados como predefinida Dígitos - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin vem com ABSOLUTAMENTE NENHUMA GARANTIA; Este software é livre, e pode redistribui-lo conforme as condições da licença GPL versão 2 ou superior. + KeePass DX \u00A9 %1$d Kunzisoft vem com ABSOLUTAMENTE NENHUMA GARANTIA; Este software é livre, e pode redistribui-lo conforme as condições da licença GPL versão 2 ou superior. \u2026 - Introduza o nome do ficheiro da base de dados: - Acedido: + Introduza o nome do ficheiro da base de dados: + Acedido Introduza a palavra-passe e/ou o ficheiro chave para desbloquear a base de dados: Cancelar - Comentários: - Confirmar palavra-passe: - Criado: - Expira: + Comentários + Confirmar palavra-passe + Criado + Expira Ficheiro chave - Modificado: + Modificado Dados da entrada não encontrados. - Palavra-passe: + Palavra-passe Guardar - Nome: - URL: - Nome de utilizador: + Nome + URL + Nome de utilizador A cifra de fluxo ArcFour não é suportada. O KeePass DX não suporta esta URI. Erro ao criar grupo. @@ -194,9 +194,13 @@ Versão: + 5 segundos + 10 segundos + 20 segundos 30 segundos 1 minuto 5 minutos + 15 minutos Nunca diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 8f5b669d0..36f729979 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -53,24 +53,24 @@ Расшифровка записи… По умолчанию Цифры 0…9 - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin Программа предоставляется БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ. Распространяется свободно по лицензии GPL v2 или новее + KeePass DX \u00A9 %1$d Kunzisoft Программа предоставляется БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ. Распространяется свободно по лицензии GPL v2 или новее … - Путь к базе KeePass: - Доступ: + Путь к базе KeePass: + Доступ Введите пароль или путь к файлу-ключу: Отмена - Комментарий: - Подтверждение: - Создано: - Истекает: + Комментарий + Подтверждение + Создано + Истекает файл-ключ - Изменено: + Изменено Данные записи не найдены. - Пароль: + Пароль Сохранить - Название: - Ссылка: - Логин: + Название + Ссылка + Логин Потоковый шифр ARC4 не поддерживается Не удалось перейти по указанному адресу Не удалось создать группу @@ -191,9 +191,13 @@ Версия: + 5 сек. + 10 сек. + 20 сек. 30 сек. 1 мин. 5 мин. + 15 мин. Никогда diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index ca9553037..0ee766dcf 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -48,23 +48,23 @@ Dešifrujem záznam Použiť toto ako predvolenú databázu Číslice - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin použitie Absolútne bez Záruky; Toto je free software, a môžete ho používať pod GPL ver. 2 alebo vyššie. + KeePass DX \u00A9 %1$d Kunzisoft použitie Absolútne bez Záruky; Toto je free software, a môžete ho používať pod GPL ver. 2 alebo vyššie. \u2026 - Vložte názov Databázy: - Pristupované: + Vložte názov Databázy: + Pristupované Vložte heslo a / alebo keyfile pre odomknutie databázy: Zrušiť - Poznámky: - Potvrdiť heslo: - Vytvorené: - Expirácia: + Poznámky + Potvrdiť heslo + Vytvorené + Expirácia Súbor Keyfile - Upravené: - Heslo: + Upravené + Heslo Uložiť - Meno: - URL: - Užívateľské meno: + Meno + URL + Užívateľské meno ArcFour stream šifra nieje podporovaná. KeePass DX nevie použiť túto uri. Chyba vytvárania Skupiny. @@ -167,9 +167,13 @@ Version: - 30 sekúnd - 1 minúta + 5 sekúnd + 10 sekúnd + 20 sekúnd + 30 sekúnd + 1 minúta 5 minút + 15 minút Nikdy diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 227ecffcd..4e575e70b 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -55,23 +55,23 @@ Dekrypterar post Använda denna databasen som standard Siffror - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin kommer HELT UTAN GARANTIER; Detta är fri programvara och du är välkommen att distribuera den utifrån villkoren i GPL version 2 eller senare. + KeePass DX \u00A9 %1$d Kunzisoft kommer HELT UTAN GARANTIER; Detta är fri programvara och du är välkommen att distribuera den utifrån villkoren i GPL version 2 eller senare. \u2026 - Ange databasnamn: - Senast använd: + Ange databasnamn: + Senast använd Ange lösenord och/eller nyckelfil för att öppna databasen: Avbryt - Kommentarer: - Bekräfta lösenord: - Skapad: - Upphör att gälla: + Kommentarer + Bekräfta lösenord + Skapad + Upphör att gälla Nyckelfil - Senast ändrad: - Lösenord: + Senast ändrad + Lösenord Spara - Namn: - URL: - Användarnamn: + Namn + URL + Användarnamn Strömchiffret ArcFour stöds inte. KeePass DX kan inte hantera denna URI. Kunde inte skapa grupp. @@ -182,9 +182,13 @@ Version: + 5 sekunder + 10 sekunder + 20 sekunder 30 sekunder 1 minut 5 minuter + 15 minuter Aldrig diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 19a3a9024..ed866ee9e 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -48,23 +48,23 @@ Розшифрування запису Використовувати як мою типову базу даних Цифри - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under the conditions of the GPL version 2 or later. + KeePass DX \u00A9 %1$d Kunzisoft comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under the conditions of the GPL version 2 or later. \u2026 - Введіть ім’я бази даних: - Доступ: + Введіть ім’я бази даних: + Доступ Введіть пароль і/або файл ключа для відкриття бази даних: Відміна - Коментар: - Підтвердження паролю: - Створено: - Закінчується: + Коментар + Підтвердження паролю + Створено + Закінчується Файл ключа - Змінено: - Пароль: + Змінено + Пароль Зберегти - Ім’я: - URL: - Ім’я користувача: + Ім’я + URL + Ім’я користувача Потокове шифрування ArcFour не підтримується. KeePass DX не може опрацювати цю адресу. Помилка створення групи. @@ -167,9 +167,13 @@ Версія: + 5 секунд + 10 секунд + 20 секунд 30 секунд 1 хвилина 5 хвилин + 15 хвилин Ніколи diff --git a/app/src/main/res/values-v23/fingerprint.xml b/app/src/main/res/values-v23/fingerprint.xml index bfef565a6..7644d0522 100644 --- a/app/src/main/res/values-v23/fingerprint.xml +++ b/app/src/main/res/values-v23/fingerprint.xml @@ -27,21 +27,21 @@ - M56.2199243,45.3815903 C56.2199243,45.3815903 65.1913567,38.8543184 80.3604294,38.8543184 C95.5295022,38.8543184 103.720044,45.2851323 103.720044,45.2851323 - M45.5181172,67.9181841 C49.9761548,62.7019025 59.122049,49.7790452 80.2279027,49.7790452 C101.333756,49.7790452 110.740506,62.0384399 114.937688,67.9181841 - M51.7375623,107.718438 C51.7375623,107.718438 48.7129745,99.6302234 48.7129745,91.6334356 C48.7129745,81.3266864 55.9028711,60.2476586 80.4057228,60.2478671 C100.798248,60.2480407 112.457463,79.7942647 112.457463,88.386575 C112.457462,99.2963939 105.619846,103.039218 100.781849,102.18762 C95.9438519,101.336021 90.4490979,97.2187731 91.0639139,92.3178681 C91.67873,87.4169631 85.2177374,81.3265129 80.7504553,81.3266871 C73.0900115,81.3269859 69.8146331,85.3921834 69.8146329,92.2700585 C69.8146324,107.718437 83.7557525,121.02713 91.6787289,121.027128 - M70.7357889,121.024995 C70.7357889,121.024995 57.4650216,106.018711 58.8888756,91.5596242 C60.5513085,74.6777941 73.9858126,70.313752 80.3788823,70.3807995 C86.771952,70.4478469 101.550994,76.8218704 101.550997,92.2895418 - M80.1599645,91.1813411 C80.1599645,91.1813411 81.1144795,102.68333 86.7971146,107.529716 C93.2390527,113.023667 105.911091,112.342743 105.911091,112.342743 + M56.2199243,45.3815903 C56.2199243,45.3815903 65.1913567,38.8543184 80.3604294,38.8543184 C95.5295022,38.8543184 103.720044,45.2851323 103.720044,45.2851323 + M45.5181172,67.9181841 C49.9761548,62.7019025 59.122049,49.7790452 80.2279027,49.7790452 C101.333756,49.7790452 110.740506,62.0384399 114.937688,67.9181841 + M51.7375623,107.718438 C51.7375623,107.718438 48.7129745,99.6302234 48.7129745,91.6334356 C48.7129745,81.3266864 55.9028711,60.2476586 80.4057228,60.2478671 C100.798248,60.2480407 112.457463,79.7942647 112.457463,88.386575 C112.457462,99.2963939 105.619846,103.039218 100.781849,102.18762 C95.9438519,101.336021 90.4490979,97.2187731 91.0639139,92.3178681 C91.67873,87.4169631 85.2177374,81.3265129 80.7504553,81.3266871 C73.0900115,81.3269859 69.8146331,85.3921834 69.8146329,92.2700585 C69.8146324,107.718437 83.7557525,121.02713 91.6787289,121.027128 + M70.7357889,121.024995 C70.7357889,121.024995 57.4650216,106.018711 58.8888756,91.5596242 C60.5513085,74.6777941 73.9858126,70.313752 80.3788823,70.3807995 C86.771952,70.4478469 101.550994,76.8218704 101.550997,92.2895418 + M80.1599645,91.1813411 C80.1599645,91.1813411 81.1144795,102.68333 86.7971146,107.529716 C93.2390527,113.023667 105.911091,112.342743 105.911091,112.342743 - M52.2735573,79.0771904 C52.2735573,79.0771904 69.2403688,96.0440006 69.2403683,96.0440014 C69.2403679,96.0440021 109.820188,55.4641819 109.820188,55.4641819 + M52.2735573,79.0771904 C52.2735573,79.0771904 69.2403688,96.0440006 69.2403683,96.0440014 C69.2403679,96.0440021 109.820188,55.4641819 109.820188,55.4641819 - M62,62 C62,62 80.5647617,80.5647617 80.564762,80.564762 C80.5647622,80.5647622 94.2921789,94.223714 98.5644262,98.5644262 - M98.5644262,62 C98.5644251,62 81.1979242,79.366503 81.1979229,79.3665033 C81.1979216,79.3665035 62,98.5644262 62,98.5644262 + M62,62 C62,62 80.5647617,80.5647617 80.564762,80.564762 C80.5647622,80.5647622 94.2921789,94.223714 98.5644262,98.5644262 + M98.5644262,62 C98.5644251,62 81.1979242,79.366503 81.1979229,79.3665033 C81.1979216,79.3665035 62,98.5644262 62,98.5644262 - M0 0 L160 0 L160 40 L0 40 Z - M0 120 L160 120 L160 160 L0 160 Z + M0 0 L160 0 L160 40 L0 40 Z + M0 120 L160 120 L160 160 L0 160 Z #deffffff #ffffffff diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 98cc0704e..d9097df0f 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -48,23 +48,23 @@ 解密条目中 使用这做为我的默认数据库 数字 - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin;软件不带有绝对担保;是自由软件,您可在遵循GPL 2或者更高版本的情况下重新发布。中文简繁体翻译:wangkf@gmail.com + KeePass DX \u00A9 %1$d Kunzisoft;软件不带有绝对担保;是自由软件,您可在遵循GPL 2或者更高版本的情况下重新发布。中文简繁体翻译:wangkf@gmail.com \u2026 - 输入数据库名: - 访问时间: + 输入数据库名: + 访问时间 输入密码和/或一个密钥文件来解锁你的数据库: 取消 - 备注: - 确认密码: - 创建: - 失效时间: + 备注 + 确认密码 + 创建 + 失效时间 密钥文件 - 修改时间:: - 密码: + 修改时间 + 密码 保存 - 名称: - 网址: - 用户名: + 名称 + 网址 + 用户名 ArcFour流密码不被支持。 KeePass DX无法处理此URI。 创建群组错误。 @@ -163,9 +163,13 @@ 你的SD卡目前尚未安装在您的设备上。你将无法加载或创建您的数据库。 + 5秒 + 10秒 + 20秒 30秒 1分钟 5分钟 + 15分钟 从不 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 1f003bee2..f02546fd8 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -48,23 +48,23 @@ 解密條目中 使用這做為我的默認資料庫 數字 - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin;軟體不帶有絕對擔保;是自由軟體,您可在遵循GPL 2或者更高版本的情況下重新發佈。中文簡繁體翻譯:wangkf@gmail.com + KeePass DX \u00A9 %1$d Kunzisoft;軟體不帶有絕對擔保;是自由軟體,您可在遵循GPL 2或者更高版本的情況下重新發佈。中文簡繁體翻譯:wangkf@gmail.com \u2026 - 輸入資料庫名: - 訪問時間: + 輸入資料庫名: + 訪問時間 輸入密碼和/或一個密鑰檔來解鎖你的資料庫: 取消 - 備註: - 確認密碼: - 創建: - 失效時間: + 備註 + 確認密碼 + 創建 + 失效時間 密鑰文件 - 修改時間:: - 密碼: + 修改時間 + 密碼 保存 - 名稱: - 網址: - 用戶名: + 名稱 + 網址 + 用戶名 ArcFour流密碼不被支援。 KeePass DX無法處理此URI。 創建群組錯誤。 @@ -163,9 +163,13 @@ 你的SD卡目前尚未安裝在您的設備上。你將無法載入或創建您的資料庫。 + 5秒 + 10秒 + 20秒 30秒 1分鐘 5分鐘 + 15分鐘 從不 diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index f80a1293d..563f9866e 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -48,7 +48,10 @@ list_size show_beta_warning show_read_only_warning - sort_key + sort_node_key + sort_group_before_key + sort_ascending_key + sort_recycle_bin_bottom_key timeout_key storage_access_framework_key 100000 @@ -60,10 +63,11 @@ settings_autofill_enable_key full_file_path_enable_key fingerprint_delete_all_key + recycle_bin_key + monospace_font_extra_fields_enable_key true true - true true true false @@ -72,12 +76,20 @@ false false false + true + true + true + false 300000 + 5000 + 10000 + 20000 30000 60000 300000 + 900000 -1 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 16ad7dbaa..5a67208eb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -39,6 +39,7 @@ File browsing requires the Open Intents File Manager, click below to install it. Due to some quirks in the file manager, browsing may not work correctly, the first time you browse. Building search index… Cancel + Allow Clipboard cleared. Clipboard error Some Samsung Android phones have a bug in the clipboard implementation that causes copying from applications to fail. For more details go to: @@ -55,24 +56,23 @@ Decrypting entry Use this as my default database Digits - KeePass DX \u00A9 %1$d Jeremy Jamet / Kunzisoft, Brian Pellin comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under the conditions of the GPL version 2 or later. + KeePass DX \u00A9 %1$d Kunzisoft comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under the conditions of the GPL version 2 or later. \u2026 - Enter database filename: - Accessed: + Accessed Enter a password and/or a key file to unlock your database: Cancel - Comments: - Confirm password: - Created: - Expires: + Comments + Confirm password + Created + Expires Key file - Modified: + Modified Entry data not found. - Password: + Password Save - Name: - URL: - User Name: + Title + URL + User Name The ArcFour stream cipher is not supported. KeePass DX cannot handle this uri. Error creating group. @@ -129,8 +129,7 @@ Hide passwords by default About Change Master Key - Copy Password - Copy User + Copy of %1$s Create Settings Application settings @@ -146,13 +145,15 @@ Rename Search Show pass + Remove the fingerprint key Go to URL Minus Never No entries in the database or group. No search results No handler for this url. - Open recent database : + Select an existing database : + Open a recent database : Don\'t search backup entries Omit \'Backup\' group from search results (applies to .kdb only) KeePass database filename: @@ -180,8 +181,17 @@ Space Search Show password - Sort by name + Sort + Ascending + Groups before + Recycle bin at the bottom DB sort order + Sort by Title + Sort by Name + Sort by Username + Sort by Creation Time + Sort by Last Modify Time + Sort by Last Access Time Special Search Search results @@ -246,11 +256,23 @@ Bytes File Path View the full file path + Use Recycle Bin + Move a group or entry to the Recycle Bin before deleting + KeePass DX need external storage permission to write a database + KeePass DX need external storage permission to read an URI not provided by a Content Provider + External storage permission denied + Can\'t perform the action without external storage permission + Fields Font + Change the font of the fields for better character visibility + 5 seconds + 10 seconds + 20 seconds 30 seconds 1 minute 5 minutes + 15 minutes Never diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 0a52580e3..717f05d3a 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -221,7 +221,6 @@ diff --git a/app/src/main/res/xml/app_preferences.xml b/app/src/main/res/xml/app_preferences.xml index 1c8da4901..25256daec 100644 --- a/app/src/main/res/xml/app_preferences.xml +++ b/app/src/main/res/xml/app_preferences.xml @@ -152,6 +152,11 @@ android:entryValues="@array/list_size_values" android:dialogTitle="@string/list_size_summary" android:defaultValue="@string/list_size_default"/> + + android:negativeButtonText="@string/entry_cancel" + android:enabled="false"/> + diff --git a/fastlane/.gitignore b/fastlane/.gitignore new file mode 100644 index 000000000..30d0742a0 --- /dev/null +++ b/fastlane/.gitignore @@ -0,0 +1 @@ +report.xml diff --git a/fastlane/Appfile b/fastlane/Appfile new file mode 100644 index 000000000..8ceb40097 --- /dev/null +++ b/fastlane/Appfile @@ -0,0 +1,2 @@ +json_key_file "./../Google_Play_Android_Developer.json" # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one +package_name "com.kunzisoft.keepass.free" # e.g. com.krausefx.app diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 000000000..059b100b2 --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,50 @@ +# This file contains the fastlane.tools configuration +# You can find the documentation at https://docs.fastlane.tools +# +# For a list of all available actions, check out +# +# https://docs.fastlane.tools/actions +# + +# Uncomment the line if you want fastlane to automatically update itself +# update_fastlane + +default_platform(:android) + +platform :android do + desc "Runs all the tests" + lane :tests do + gradle(task: "test") + end + + desc "Build a new Beta version" + lane :build_beta_google_free do |options| + gradle( + task: "assemble", + flavor: "free_google", + build_type: "Release", + print_command: false, + properties: { + "android.injected.signing.store.file" => options[:storefile], + "android.injected.signing.store.password" => options[:storepass], + "android.injected.signing.key.alias" => options[:keyalias], + "android.injected.signing.key.password" => options[:keypass], + } + ) + end + + desc "Deploy a new Beta version to the Google Play" + lane :deploy_beta_google_free do + upload_to_play_store( + track: "beta", + skip_upload_metadata: "false", + skip_upload_images: "true", + skip_upload_screenshots: "false", + apk: "./app/build/outputs/apk/free_google/release/app-free_google-release.apk", + validate_only: "false", + ) + gradle( + task: 'clean' + ) + end +end \ No newline at end of file diff --git a/fastlane/README.md b/fastlane/README.md new file mode 100644 index 000000000..553e7173d --- /dev/null +++ b/fastlane/README.md @@ -0,0 +1,30 @@ +fastlane documentation +================ +# Installation + +Install _fastlane_ using +``` +[sudo] gem install fastlane -NV +``` +or alternatively using `brew cask install fastlane` + +# Available Actions +## Android +``` +fastlane tests +``` +Runs all the tests + +``` +fastlane build_beta_google_free storefile:"" storepass:"" keyalias:"" keypass:"" +``` +Build a new Beta version +``` +fastlane deploy_beta_google_free +``` +Deploy a new Beta version to the Google Play + +---- + +More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). +The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/fastlane/metadata/android/en-US/changelogs/3.txt b/fastlane/metadata/android/en-US/changelogs/3.txt new file mode 100644 index 000000000..1dd571893 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/3.txt @@ -0,0 +1,9 @@ + * New database workflow with new screens and folder selection + * Settings for default password generation + * Fingerprint dialog for explanations + * Setting to disable fingerprint + * Directly opening kdbx file + * Setting to disable notifications + * Setting to lock database when screen is shut off + * Merge KeePassDroid 2.2.0.9 + * Add corruption fix mode diff --git a/fastlane/metadata/android/en-US/changelogs/4.txt b/fastlane/metadata/android/en-US/changelogs/4.txt new file mode 100644 index 000000000..bec2d4628 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/4.txt @@ -0,0 +1,7 @@ + * Show only file name + * Setting for full path + * Add information for each database file + * Setting to delete fingerprints + * Solve bugs when change fingerprint + * Delete view assignment for fingerprint opening + * Merge KeePassDroid 2.2.1 diff --git a/fastlane/metadata/android/en-US/full_description.txt b/fastlane/metadata/android/en-US/full_description.txt new file mode 100644 index 000000000..5432ea828 --- /dev/null +++ b/fastlane/metadata/android/en-US/full_description.txt @@ -0,0 +1,15 @@ +If you want a light material design Keepass client to manage keys and passwords in secure database, you're in the right place ! + +Features : + * Create database files / entries and groups + * Support for .kdb and .kdbx files (version 1 to 4) + * Open database, copy username / password, open URI / URL + * Fingerprint for fast unlocking + * Material design with themes + * AutoFill and Integration (Development in progress) + * Precise management of settings + +Keepass DX is opensource and ad-free. +You can donate for a better service and a quick development of your features. + +Any issue : https://github.com/Kunzisoft/KeePassDX/issues \ No newline at end of file diff --git a/art/feature_graphic.png b/fastlane/metadata/android/en-US/images/featureGraphic.png similarity index 100% rename from art/feature_graphic.png rename to fastlane/metadata/android/en-US/images/featureGraphic.png diff --git a/art/logo.png b/fastlane/metadata/android/en-US/images/icon.png similarity index 100% rename from art/logo.png rename to fastlane/metadata/android/en-US/images/icon.png diff --git a/art/screen0.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/screen0.jpg similarity index 100% rename from art/screen0.jpg rename to fastlane/metadata/android/en-US/images/phoneScreenshots/screen0.jpg diff --git a/art/screen1.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/screen1.jpg similarity index 100% rename from art/screen1.jpg rename to fastlane/metadata/android/en-US/images/phoneScreenshots/screen1.jpg diff --git a/art/screen2.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/screen2.jpg similarity index 100% rename from art/screen2.jpg rename to fastlane/metadata/android/en-US/images/phoneScreenshots/screen2.jpg diff --git a/art/screen3.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/screen3.jpg similarity index 100% rename from art/screen3.jpg rename to fastlane/metadata/android/en-US/images/phoneScreenshots/screen3.jpg diff --git a/art/screen4.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/screen4.jpg similarity index 100% rename from art/screen4.jpg rename to fastlane/metadata/android/en-US/images/phoneScreenshots/screen4.jpg diff --git a/art/screen5.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/screen5.jpg similarity index 100% rename from art/screen5.jpg rename to fastlane/metadata/android/en-US/images/phoneScreenshots/screen5.jpg diff --git a/art/screen6.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/screen6.jpg similarity index 100% rename from art/screen6.jpg rename to fastlane/metadata/android/en-US/images/phoneScreenshots/screen6.jpg diff --git a/art/screen7.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/screen7.jpg similarity index 100% rename from art/screen7.jpg rename to fastlane/metadata/android/en-US/images/phoneScreenshots/screen7.jpg diff --git a/fastlane/metadata/android/en-US/short_description.txt b/fastlane/metadata/android/en-US/short_description.txt new file mode 100644 index 000000000..511a64011 --- /dev/null +++ b/fastlane/metadata/android/en-US/short_description.txt @@ -0,0 +1 @@ +KeePass deluxe to manage your passwords in a secure way \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/title.txt b/fastlane/metadata/android/en-US/title.txt new file mode 100644 index 000000000..d8058b033 --- /dev/null +++ b/fastlane/metadata/android/en-US/title.txt @@ -0,0 +1 @@ +KeePass DX \ No newline at end of file diff --git a/fastlane/metadata/android/fr-FR/changelogs/3.txt b/fastlane/metadata/android/fr-FR/changelogs/3.txt new file mode 100644 index 000000000..3ad07d55e --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/3.txt @@ -0,0 +1,9 @@ + * Nouveau workflow de base de données avec nouveaux écrans et sélection de dossier + * Paramètres pour la génération de mots de passe + * Dialogue d'empreinte digitale pour les explications + * Paramètre pour désactiver l'empreinte digitale + * Ouverture direct des fichiers kdbx + * Paramètre de désactivation des notifications + * Paramètre de fermeture de la base de données quand l'écran s’éteint + * Merge KeePassDroid 2.2.0.9 + * Ajout de la résolution de corruption diff --git a/fastlane/metadata/android/fr-FR/changelogs/4.txt b/fastlane/metadata/android/fr-FR/changelogs/4.txt new file mode 100644 index 000000000..c629c0db4 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/4.txt @@ -0,0 +1,7 @@ + * Affichage uniquement du nom du fichier + * Paramètre pour le chemin complet + * Ajout des informations pour chaque fichier de base de données + * Paramètre pour supprimer les empreintes digitales + * Résolution des bugs lors du changement d'empreinte digitale + * Suppression de l'attribution de la vue pour l'ouverture par empreinte digitale + * Merge KeePassDroid 2.2.1 diff --git a/fastlane/metadata/android/fr-FR/full_description.txt b/fastlane/metadata/android/fr-FR/full_description.txt new file mode 100644 index 000000000..4b2fb4179 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/full_description.txt @@ -0,0 +1,15 @@ +Si vous voulez un client Keepass material design pour gérer vos clés et mots de passe dans une base de données sécurisée, vous êtes au bon endroit ! + +Fonctionnalités : + * Création de fichiers de base de données / entrées et groupes + * Support des fichiers .kdb et .kdbx (version 1 à 4) + * Ouverture de la base de données, copie du nom d'utilisateur / mot de passe, ouverture des URI / URL + * Empreinte digitale pour déblocage rapide + * Material design avec thèmes + * AutoFill et Intégration (Développement en cours) + * Gestion précise des paramètres + +Keepass DX est opensource et sans publicité. +Vous pouvez faire un don pour un meilleur service et un développement rapide de vos fonctionnalités. + +Vous avez un bug : https://github.com/Kunzisoft/KeePassDX/issues \ No newline at end of file diff --git a/fastlane/metadata/android/fr-FR/short_description.txt b/fastlane/metadata/android/fr-FR/short_description.txt new file mode 100644 index 000000000..1195f1afc --- /dev/null +++ b/fastlane/metadata/android/fr-FR/short_description.txt @@ -0,0 +1 @@ +KeePass deluxe pour gérer vos mots de passe de façon sécurisée \ No newline at end of file