mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix search / Fix icon - back #138 / Upgrade changelogs
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
KeepassDX (2.5.0.0beta16)
|
KeepassDX (2.5.0.0beta16)
|
||||||
* New search in a single fragment
|
* New search in a single fragment
|
||||||
* Search suggestions
|
* Search suggestions
|
||||||
* Fix read-only mode
|
* Added the display of usernames
|
||||||
* Added translations
|
* Added translations
|
||||||
* Fix parcelable / toolbar
|
* Fix read-only mode
|
||||||
|
* Fix parcelable / toolbar / back
|
||||||
|
|
||||||
KeepassDX (2.5.0.0beta15)
|
KeepassDX (2.5.0.0beta15)
|
||||||
* Read only mode
|
* Read only mode
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ public class PwEntryTestV4 extends TestCase {
|
|||||||
|
|
||||||
entry.setBackgroupColor("blue");
|
entry.setBackgroupColor("blue");
|
||||||
entry.putProtectedBinary("key1", new ProtectedBinary(false, new byte[] {0,1}));
|
entry.putProtectedBinary("key1", new ProtectedBinary(false, new byte[] {0,1}));
|
||||||
entry.setCustomIcon(new PwIconCustom(UUID.randomUUID(), new byte[0]));
|
entry.setIconCustom(new PwIconCustom(UUID.randomUUID(), new byte[0]));
|
||||||
entry.setForegroundColor("red");
|
entry.setForegroundColor("red");
|
||||||
entry.addToHistory(new PwEntryV4());
|
entry.addToHistory(new PwEntryV4());
|
||||||
entry.setIcon(new PwIconStandard(5));
|
entry.setIconStandard(new PwIconStandard(5));
|
||||||
entry.setOverrideURL("override");
|
entry.setOverrideURL("override");
|
||||||
entry.setParent(new PwGroupV4());
|
entry.setParent(new PwGroupV4());
|
||||||
entry.addExtraField("key2", new ProtectedString(false, "value2"));
|
entry.addExtraField("key2", new ProtectedString(false, "value2"));
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import com.kunzisoft.keepass.database.ExtraFields;
|
|||||||
import com.kunzisoft.keepass.database.PwDatabase;
|
import com.kunzisoft.keepass.database.PwDatabase;
|
||||||
import com.kunzisoft.keepass.database.PwEntry;
|
import com.kunzisoft.keepass.database.PwEntry;
|
||||||
import com.kunzisoft.keepass.database.security.ProtectedString;
|
import com.kunzisoft.keepass.database.security.ProtectedString;
|
||||||
import com.kunzisoft.keepass.icons.IconPackChooser;
|
|
||||||
import com.kunzisoft.keepass.lock.LockingActivity;
|
import com.kunzisoft.keepass.lock.LockingActivity;
|
||||||
import com.kunzisoft.keepass.lock.LockingHideActivity;
|
import com.kunzisoft.keepass.lock.LockingHideActivity;
|
||||||
import com.kunzisoft.keepass.notifications.NotificationCopyingService;
|
import com.kunzisoft.keepass.notifications.NotificationCopyingService;
|
||||||
@@ -84,6 +83,8 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
private ClipboardHelper clipboardHelper;
|
private ClipboardHelper clipboardHelper;
|
||||||
private boolean firstLaunchOfActivity;
|
private boolean firstLaunchOfActivity;
|
||||||
|
|
||||||
|
private int iconColor;
|
||||||
|
|
||||||
public static void launch(Activity act, PwEntry pw, boolean readOnly) {
|
public static void launch(Activity act, PwEntry pw, boolean readOnly) {
|
||||||
if (LockingActivity.checkTimeIsAllowedOrFinish(act)) {
|
if (LockingActivity.checkTimeIsAllowedOrFinish(act)) {
|
||||||
Intent intent = new Intent(act, EntryActivity.class);
|
Intent intent = new Intent(act, EntryActivity.class);
|
||||||
@@ -125,6 +126,11 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve the textColor to tint the icon
|
||||||
|
int[] attrs = {R.attr.textColorInverse};
|
||||||
|
TypedArray ta = getTheme().obtainStyledAttributes(attrs);
|
||||||
|
iconColor = ta.getColor(0, Color.WHITE);
|
||||||
|
|
||||||
// Refresh Menu contents in case onCreateMenuOptions was called before mEntry was set
|
// Refresh Menu contents in case onCreateMenuOptions was called before mEntry was set
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
@@ -312,15 +318,7 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
mEntry.startToManageFieldReferences(pm);
|
mEntry.startToManageFieldReferences(pm);
|
||||||
|
|
||||||
// Assign title icon
|
// Assign title icon
|
||||||
if (IconPackChooser.getSelectedIconPack(this).tintable()) {
|
db.getDrawFactory().assignDatabaseIconTo(this, titleIconView, mEntry.getIcon(), iconColor);
|
||||||
// Retrieve the textColor to tint the icon
|
|
||||||
int[] attrs = {R.attr.textColorInverse};
|
|
||||||
TypedArray ta = getTheme().obtainStyledAttributes(attrs);
|
|
||||||
int iconColor = ta.getColor(0, Color.WHITE);
|
|
||||||
App.getDB().getDrawFactory().assignDatabaseIconTo(this, titleIconView, mEntry.getIcon(), true, iconColor);
|
|
||||||
} else {
|
|
||||||
App.getDB().getDrawFactory().assignDatabaseIconTo(this, titleIconView, mEntry.getIcon());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign title text
|
// Assign title text
|
||||||
titleView.setText(mEntry.getVisualTitle());
|
titleView.setText(mEntry.getVisualTitle());
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ import com.kunzisoft.keepass.database.action.node.UpdateEntryRunnable;
|
|||||||
import com.kunzisoft.keepass.database.security.ProtectedString;
|
import com.kunzisoft.keepass.database.security.ProtectedString;
|
||||||
import com.kunzisoft.keepass.dialogs.GeneratePasswordDialogFragment;
|
import com.kunzisoft.keepass.dialogs.GeneratePasswordDialogFragment;
|
||||||
import com.kunzisoft.keepass.dialogs.IconPickerDialogFragment;
|
import com.kunzisoft.keepass.dialogs.IconPickerDialogFragment;
|
||||||
import com.kunzisoft.keepass.icons.IconPackChooser;
|
|
||||||
import com.kunzisoft.keepass.lock.LockingActivity;
|
import com.kunzisoft.keepass.lock.LockingActivity;
|
||||||
import com.kunzisoft.keepass.lock.LockingHideActivity;
|
import com.kunzisoft.keepass.lock.LockingHideActivity;
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||||
@@ -71,7 +70,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static com.kunzisoft.keepass.dialogs.IconPickerDialogFragment.UNDEFINED_ICON_ID;
|
import static com.kunzisoft.keepass.dialogs.IconPickerDialogFragment.KEY_ICON_STANDARD;
|
||||||
|
|
||||||
public class EntryEditActivity extends LockingHideActivity
|
public class EntryEditActivity extends LockingHideActivity
|
||||||
implements IconPickerDialogFragment.IconPickerListener,
|
implements IconPickerDialogFragment.IconPickerListener,
|
||||||
@@ -89,10 +88,12 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
public static final int ADD_OR_UPDATE_ENTRY_REQUEST_CODE = 7129;
|
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";
|
public static final String ADD_OR_UPDATE_ENTRY_KEY = "ADD_OR_UPDATE_ENTRY_KEY";
|
||||||
|
|
||||||
|
private Database database;
|
||||||
|
|
||||||
protected PwEntry mEntry;
|
protected PwEntry mEntry;
|
||||||
protected PwEntry mCallbackNewEntry;
|
protected PwEntry mCallbackNewEntry;
|
||||||
protected boolean mIsNew;
|
protected boolean mIsNew;
|
||||||
protected int mSelectedIconID = UNDEFINED_ICON_ID;
|
protected PwIconStandard mSelectedIconStandard;
|
||||||
|
|
||||||
// Views
|
// Views
|
||||||
private ScrollView scrollView;
|
private ScrollView scrollView;
|
||||||
@@ -143,7 +144,6 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
setContentView(R.layout.entry_edit);
|
setContentView(R.layout.entry_edit);
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
toolbar.setTitle(getString(R.string.app_name));
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
assert getSupportActionBar() != null;
|
assert getSupportActionBar() != null;
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
@@ -162,8 +162,8 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
entryExtraFieldsContainer = findViewById(R.id.advanced_container);
|
entryExtraFieldsContainer = findViewById(R.id.advanced_container);
|
||||||
|
|
||||||
// Likely the app has been killed exit the activity
|
// Likely the app has been killed exit the activity
|
||||||
Database db = App.getDB();
|
database = App.getDB();
|
||||||
if ( ! db.getLoaded() ) {
|
if ( ! database.getLoaded() ) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -176,18 +176,16 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
TypedArray ta = getTheme().obtainStyledAttributes(attrs);
|
TypedArray ta = getTheme().obtainStyledAttributes(attrs);
|
||||||
iconColor = ta.getColor(0, Color.WHITE);
|
iconColor = ta.getColor(0, Color.WHITE);
|
||||||
|
|
||||||
PwDatabase pm = db.getPwDatabase();
|
mSelectedIconStandard = database.getPwDatabase().getIconFactory().getUnknownIcon();
|
||||||
|
|
||||||
|
PwDatabase pm = database.getPwDatabase();
|
||||||
if ( uuidBytes == null ) {
|
if ( uuidBytes == null ) {
|
||||||
PwGroupId parentId = intent.getParcelableExtra(KEY_PARENT);
|
PwGroupId parentId = intent.getParcelableExtra(KEY_PARENT);
|
||||||
PwGroup parent = pm.getGroupByGroupId(parentId);
|
PwGroup parent = pm.getGroupByGroupId(parentId);
|
||||||
mEntry = db.createEntry(parent);
|
mEntry = database.createEntry(parent);
|
||||||
mIsNew = true;
|
mIsNew = true;
|
||||||
// Add the default icon
|
// Add the default icon
|
||||||
if (IconPackChooser.getSelectedIconPack(this).tintable()) {
|
database.getDrawFactory().assignDefaultDatabaseIconTo(this, entryIconView, iconColor);
|
||||||
App.getDB().getDrawFactory().assignDefaultDatabaseIconTo(this, entryIconView, true, iconColor);
|
|
||||||
} else {
|
|
||||||
App.getDB().getDrawFactory().assignDefaultDatabaseIconTo(this, entryIconView);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
UUID uuid = Types.bytestoUUID(uuidBytes);
|
UUID uuid = Types.bytestoUUID(uuidBytes);
|
||||||
mEntry = pm.getEntryByUUIDId(uuid);
|
mEntry = pm.getEntryByUUIDId(uuid);
|
||||||
@@ -195,8 +193,12 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
fillData();
|
fillData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assign title
|
||||||
|
setTitle((mIsNew) ? getString(R.string.add_entry) : getString(R.string.edit_entry));
|
||||||
|
|
||||||
// Retrieve the icon after an orientation change
|
// Retrieve the icon after an orientation change
|
||||||
if (savedInstanceState != null && savedInstanceState.containsKey(IconPickerDialogFragment.KEY_ICON_ID)) {
|
if (savedInstanceState != null
|
||||||
|
&& savedInstanceState.containsKey(KEY_ICON_STANDARD)) {
|
||||||
iconPicked(savedInstanceState);
|
iconPicked(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,9 +261,9 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
EntryEditActivity act = EntryEditActivity.this;
|
EntryEditActivity act = EntryEditActivity.this;
|
||||||
RunnableOnFinish task;
|
RunnableOnFinish task;
|
||||||
if ( mIsNew ) {
|
if ( mIsNew ) {
|
||||||
task = new AddEntryRunnable(act, App.getDB(), mCallbackNewEntry, onFinish);
|
task = new AddEntryRunnable(act, database, mCallbackNewEntry, onFinish);
|
||||||
} else {
|
} else {
|
||||||
task = new UpdateEntryRunnable(act, App.getDB(), mEntry, mCallbackNewEntry, onFinish);
|
task = new UpdateEntryRunnable(act, database, mEntry, mCallbackNewEntry, onFinish);
|
||||||
}
|
}
|
||||||
task.setUpdateProgressTaskStatus(
|
task.setUpdateProgressTaskStatus(
|
||||||
new UpdateProgressTaskStatus(this,
|
new UpdateProgressTaskStatus(this,
|
||||||
@@ -409,7 +411,7 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
newEntry.setLastModificationTime(new PwDate());
|
newEntry.setLastModificationTime(new PwDate());
|
||||||
|
|
||||||
newEntry.setTitle(entryTitleView.getText().toString());
|
newEntry.setTitle(entryTitleView.getText().toString());
|
||||||
newEntry.setIcon(retrieveIcon());
|
newEntry.setIconStandard(retrieveIcon());
|
||||||
|
|
||||||
newEntry.setUrl(entryUrlView.getText().toString());
|
newEntry.setUrl(entryUrlView.getText().toString());
|
||||||
newEntry.setUsername(entryUserNameView.getText().toString());
|
newEntry.setUsername(entryUserNameView.getText().toString());
|
||||||
@@ -436,14 +438,14 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the icon by the selection, or the first icon in the list if the entry is new or the last one
|
* Retrieve the icon by the selection, or the first icon in the list if the entry is new or the last one
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private PwIconStandard retrieveIcon() {
|
private PwIconStandard retrieveIcon() {
|
||||||
if(mSelectedIconID != UNDEFINED_ICON_ID)
|
|
||||||
return App.getDB().getPwDatabase().getIconFactory().getIcon(mSelectedIconID);
|
if (!mSelectedIconStandard.isUnknown())
|
||||||
|
return mSelectedIconStandard;
|
||||||
else {
|
else {
|
||||||
if (mIsNew) {
|
if (mIsNew) {
|
||||||
return App.getDB().getPwDatabase().getIconFactory().getKeyIcon();
|
return database.getPwDatabase().getIconFactory().getKeyIcon();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Keep previous icon, if no new one was selected
|
// Keep previous icon, if no new one was selected
|
||||||
@@ -475,13 +477,18 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assignIconView() {
|
||||||
|
database.getDrawFactory()
|
||||||
|
.assignDatabaseIconTo(
|
||||||
|
this,
|
||||||
|
entryIconView,
|
||||||
|
mEntry.getIcon(),
|
||||||
|
iconColor);
|
||||||
|
}
|
||||||
|
|
||||||
protected void fillData() {
|
protected void fillData() {
|
||||||
|
|
||||||
if (IconPackChooser.getSelectedIconPack(this).tintable()) {
|
assignIconView();
|
||||||
App.getDB().getDrawFactory().assignDatabaseIconTo(this, entryIconView, mEntry.getIcon(), true, iconColor);
|
|
||||||
} else {
|
|
||||||
App.getDB().getDrawFactory().assignDatabaseIconTo(this, entryIconView, mEntry.getIcon());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't start the field reference manager, we want to see the raw ref
|
// Don't start the field reference manager, we want to see the raw ref
|
||||||
mEntry.stopToManageFieldReferences();
|
mEntry.stopToManageFieldReferences();
|
||||||
@@ -515,14 +522,15 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void iconPicked(Bundle bundle) {
|
public void iconPicked(Bundle bundle) {
|
||||||
mSelectedIconID = bundle.getInt(IconPickerDialogFragment.KEY_ICON_ID);
|
mSelectedIconStandard = bundle.getParcelable(KEY_ICON_STANDARD);
|
||||||
entryIconView.setImageResource(IconPackChooser.getSelectedIconPack(this).iconToResId(mSelectedIconID));
|
mEntry.setIconStandard(mSelectedIconStandard);
|
||||||
|
assignIconView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
if (mSelectedIconID != UNDEFINED_ICON_ID) {
|
if (!mSelectedIconStandard.isUnknown()) {
|
||||||
outState.putInt(IconPickerDialogFragment.KEY_ICON_ID, mSelectedIconID);
|
outState.putParcelable(KEY_ICON_STANDARD, mSelectedIconStandard);
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import com.kunzisoft.keepass.database.PwDatabase;
|
|||||||
import com.kunzisoft.keepass.database.PwEntry;
|
import com.kunzisoft.keepass.database.PwEntry;
|
||||||
import com.kunzisoft.keepass.database.PwGroup;
|
import com.kunzisoft.keepass.database.PwGroup;
|
||||||
import com.kunzisoft.keepass.database.PwGroupId;
|
import com.kunzisoft.keepass.database.PwGroupId;
|
||||||
|
import com.kunzisoft.keepass.database.PwGroupV4;
|
||||||
import com.kunzisoft.keepass.database.PwIcon;
|
import com.kunzisoft.keepass.database.PwIcon;
|
||||||
import com.kunzisoft.keepass.database.PwIconStandard;
|
import com.kunzisoft.keepass.database.PwIconStandard;
|
||||||
import com.kunzisoft.keepass.database.PwNode;
|
import com.kunzisoft.keepass.database.PwNode;
|
||||||
@@ -79,7 +80,6 @@ import com.kunzisoft.keepass.dialogs.GroupEditDialogFragment;
|
|||||||
import com.kunzisoft.keepass.dialogs.IconPickerDialogFragment;
|
import com.kunzisoft.keepass.dialogs.IconPickerDialogFragment;
|
||||||
import com.kunzisoft.keepass.dialogs.ReadOnlyDialog;
|
import com.kunzisoft.keepass.dialogs.ReadOnlyDialog;
|
||||||
import com.kunzisoft.keepass.dialogs.SortDialogFragment;
|
import com.kunzisoft.keepass.dialogs.SortDialogFragment;
|
||||||
import com.kunzisoft.keepass.icons.IconPackChooser;
|
|
||||||
import com.kunzisoft.keepass.lock.LockingActivity;
|
import com.kunzisoft.keepass.lock.LockingActivity;
|
||||||
import com.kunzisoft.keepass.password.AssignPasswordHelper;
|
import com.kunzisoft.keepass.password.AssignPasswordHelper;
|
||||||
import com.kunzisoft.keepass.selection.EntrySelectionHelper;
|
import com.kunzisoft.keepass.selection.EntrySelectionHelper;
|
||||||
@@ -136,6 +136,8 @@ public class GroupActivity extends LockingActivity
|
|||||||
|
|
||||||
private SearchEntryCursorAdapter searchSuggestionAdapter;
|
private SearchEntryCursorAdapter searchSuggestionAdapter;
|
||||||
|
|
||||||
|
private int iconColor;
|
||||||
|
|
||||||
// After a database creation
|
// After a database creation
|
||||||
public static void launch(Activity act) {
|
public static void launch(Activity act) {
|
||||||
launch(act, READ_ONLY_DEFAULT);
|
launch(act, READ_ONLY_DEFAULT);
|
||||||
@@ -267,6 +269,11 @@ public class GroupActivity extends LockingActivity
|
|||||||
nodeToMove = null;
|
nodeToMove = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Retrieve the textColor to tint the icon
|
||||||
|
int[] attrs = {R.attr.textColorInverse};
|
||||||
|
TypedArray ta = getTheme().obtainStyledAttributes(attrs);
|
||||||
|
iconColor = ta.getColor(0, Color.WHITE);
|
||||||
|
|
||||||
String fragmentTag = LIST_NODES_FRAGMENT_TAG;
|
String fragmentTag = LIST_NODES_FRAGMENT_TAG;
|
||||||
if (currentGroupIsASearch)
|
if (currentGroupIsASearch)
|
||||||
fragmentTag = SEARCH_FRAGMENT_TAG;
|
fragmentTag = SEARCH_FRAGMENT_TAG;
|
||||||
@@ -439,15 +446,7 @@ public class GroupActivity extends LockingActivity
|
|||||||
// Assign the group icon depending of IconPack or custom icon
|
// Assign the group icon depending of IconPack or custom icon
|
||||||
iconView.setVisibility(View.VISIBLE);
|
iconView.setVisibility(View.VISIBLE);
|
||||||
if (mCurrentGroup != null) {
|
if (mCurrentGroup != null) {
|
||||||
if (IconPackChooser.getSelectedIconPack(this).tintable()) {
|
database.getDrawFactory().assignDatabaseIconTo(this, iconView, mCurrentGroup.getIcon(), iconColor);
|
||||||
// Retrieve the textColor to tint the icon
|
|
||||||
int[] attrs = {R.attr.textColorInverse};
|
|
||||||
TypedArray ta = getTheme().obtainStyledAttributes(attrs);
|
|
||||||
int iconColor = ta.getColor(0, Color.WHITE);
|
|
||||||
App.getDB().getDrawFactory().assignDatabaseIconTo(this, iconView, mCurrentGroup.getIcon(), true, iconColor);
|
|
||||||
} else {
|
|
||||||
App.getDB().getDrawFactory().assignDatabaseIconTo(this, iconView, mCurrentGroup.getIcon());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toolbar != null) {
|
if (toolbar != null) {
|
||||||
if (mCurrentGroup.containsParent())
|
if (mCurrentGroup.containsParent())
|
||||||
@@ -706,7 +705,8 @@ public class GroupActivity extends LockingActivity
|
|||||||
// Refresh the elements
|
// Refresh the elements
|
||||||
assignGroupViewElements();
|
assignGroupViewElements();
|
||||||
// Refresh suggestions to change preferences
|
// Refresh suggestions to change preferences
|
||||||
searchSuggestionAdapter.reInit(this);
|
if (searchSuggestionAdapter != null)
|
||||||
|
searchSuggestionAdapter.reInit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -978,7 +978,7 @@ public class GroupActivity extends LockingActivity
|
|||||||
try {
|
try {
|
||||||
iconStandard = (PwIconStandard) icon;
|
iconStandard = (PwIconStandard) icon;
|
||||||
} catch (Exception ignored) {} // TODO custom icon
|
} catch (Exception ignored) {} // TODO custom icon
|
||||||
newGroup.setIcon(iconStandard);
|
newGroup.setIconStandard(iconStandard);
|
||||||
|
|
||||||
// If group created save it in the database
|
// If group created save it in the database
|
||||||
AddGroupRunnable addGroupRunnable = new AddGroupRunnable(this,
|
AddGroupRunnable addGroupRunnable = new AddGroupRunnable(this,
|
||||||
@@ -1000,8 +1000,11 @@ public class GroupActivity extends LockingActivity
|
|||||||
updateGroup.setName(name);
|
updateGroup.setName(name);
|
||||||
try {
|
try {
|
||||||
iconStandard = (PwIconStandard) icon;
|
iconStandard = (PwIconStandard) icon;
|
||||||
} catch (Exception ignored) {} // TODO custom icon
|
updateGroup = ((PwGroupV4) oldGroupToUpdate).clone(); // TODO generalize
|
||||||
updateGroup.setIcon(iconStandard);
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} // TODO custom icon
|
||||||
|
updateGroup.setIconStandard(iconStandard);
|
||||||
|
|
||||||
if (listNodesFragment != null)
|
if (listNodesFragment != null)
|
||||||
listNodesFragment.removeNode(oldGroupToUpdate);
|
listNodesFragment.removeNode(oldGroupToUpdate);
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import com.kunzisoft.keepass.database.PwEntry;
|
|||||||
import com.kunzisoft.keepass.database.PwGroup;
|
import com.kunzisoft.keepass.database.PwGroup;
|
||||||
import com.kunzisoft.keepass.database.PwNode;
|
import com.kunzisoft.keepass.database.PwNode;
|
||||||
import com.kunzisoft.keepass.database.SortNodeEnum;
|
import com.kunzisoft.keepass.database.SortNodeEnum;
|
||||||
import com.kunzisoft.keepass.icons.IconPackChooser;
|
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||||
import com.kunzisoft.keepass.utils.Util;
|
import com.kunzisoft.keepass.utils.Util;
|
||||||
|
|
||||||
@@ -224,20 +223,16 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
|||||||
public void onBindViewHolder(@NonNull BasicViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull BasicViewHolder holder, int position) {
|
||||||
PwNode subNode = nodeSortedList.get(position);
|
PwNode subNode = nodeSortedList.get(position);
|
||||||
// Assign image
|
// Assign image
|
||||||
if (IconPackChooser.getSelectedIconPack(context).tintable()) {
|
int iconColor = Color.BLACK;
|
||||||
int iconColor = Color.BLACK;
|
switch (subNode.getType()) {
|
||||||
switch (subNode.getType()) {
|
case GROUP:
|
||||||
case GROUP:
|
iconColor = iconGroupColor;
|
||||||
iconColor = iconGroupColor;
|
break;
|
||||||
break;
|
case ENTRY:
|
||||||
case ENTRY:
|
iconColor = iconEntryColor;
|
||||||
iconColor = iconEntryColor;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
database.getDrawFactory().assignDatabaseIconTo(context, holder.icon, subNode.getIcon(), true, iconColor);
|
|
||||||
} else {
|
|
||||||
database.getDrawFactory().assignDatabaseIconTo(context, holder.icon, subNode.getIcon());
|
|
||||||
}
|
}
|
||||||
|
database.getDrawFactory().assignDatabaseIconTo(context, holder.icon, subNode.getIcon(), iconColor);
|
||||||
// Assign text
|
// Assign text
|
||||||
holder.text.setText(subNode.getTitle());
|
holder.text.setText(subNode.getTitle());
|
||||||
// Assign click
|
// Assign click
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import com.kunzisoft.keepass.database.PwEntry;
|
|||||||
import com.kunzisoft.keepass.database.PwIcon;
|
import com.kunzisoft.keepass.database.PwIcon;
|
||||||
import com.kunzisoft.keepass.database.PwIconFactory;
|
import com.kunzisoft.keepass.database.PwIconFactory;
|
||||||
import com.kunzisoft.keepass.database.cursor.EntryCursor;
|
import com.kunzisoft.keepass.database.cursor.EntryCursor;
|
||||||
import com.kunzisoft.keepass.icons.IconPackChooser;
|
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -102,16 +101,15 @@ public class SearchEntryCursorAdapter extends CursorAdapter {
|
|||||||
ViewHolder viewHolder = (ViewHolder) view.getTag();
|
ViewHolder viewHolder = (ViewHolder) view.getTag();
|
||||||
|
|
||||||
// Assign image
|
// Assign image
|
||||||
if (IconPackChooser.getSelectedIconPack(context).tintable()) {
|
database.getDrawFactory().assignDatabaseIconTo(context, viewHolder.imageViewIcon, icon, iconColor);
|
||||||
database.getDrawFactory().assignDatabaseIconTo(context, viewHolder.imageViewIcon, icon, true, iconColor);
|
|
||||||
} else {
|
|
||||||
database.getDrawFactory().assignDatabaseIconTo(context, viewHolder.imageViewIcon, icon);
|
|
||||||
}
|
|
||||||
// Assign title
|
// Assign title
|
||||||
String showTitle = PwEntry.getVisualTitle(false, title, username, url, uuid);
|
String showTitle = PwEntry.getVisualTitle(false, title, username, url, uuid);
|
||||||
viewHolder.textViewTitle.setText(showTitle);
|
viewHolder.textViewTitle.setText(showTitle);
|
||||||
if (displayUsername && !username.isEmpty()) {
|
if (displayUsername && !username.isEmpty()) {
|
||||||
viewHolder.textViewSubTitle.setText(String.format("(%s)", username));
|
viewHolder.textViewSubTitle.setText(String.format("(%s)", username));
|
||||||
|
} else {
|
||||||
|
viewHolder.textViewSubTitle.setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,17 +205,21 @@ public class Database {
|
|||||||
// TODO real content provider
|
// TODO real content provider
|
||||||
if (!query.isEmpty()) {
|
if (!query.isEmpty()) {
|
||||||
PwGroup searchResult = search(query, 6);
|
PwGroup searchResult = search(query, 6);
|
||||||
|
PwVersion version = getPwDatabase().getVersion();
|
||||||
for (int i=0; i < searchResult.numbersOfChildEntries(); i++) {
|
for (int i=0; i < searchResult.numbersOfChildEntries(); i++) {
|
||||||
PwEntry entry = searchResult.getChildEntryAt(i);
|
PwEntry entry = searchResult.getChildEntryAt(i);
|
||||||
try {
|
if (!entry.isMetaStream()) { // TODO metastream
|
||||||
switch (getPwDatabase().getVersion()) {
|
try {
|
||||||
case V3:
|
switch (version) {
|
||||||
cursor.addEntry((PwEntryV3) entry);
|
case V3:
|
||||||
case V4:
|
cursor.addEntry((PwEntryV3) entry);
|
||||||
cursor.addEntry((PwEntryV4) entry);
|
continue;
|
||||||
|
case V4:
|
||||||
|
cursor.addEntry((PwEntryV4) entry);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "This version of PwEntry can't be added to the cursor", e);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "This version of PwGroup can't be populated", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,20 +227,22 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void populateEntry(PwEntry pwEntry, EntryCursor cursor) {
|
public void populateEntry(PwEntry pwEntry, EntryCursor cursor) {
|
||||||
// TODO invert field reference manager
|
|
||||||
pwEntry.startToManageFieldReferences(getPwDatabase());
|
|
||||||
PwIconFactory iconFactory = getPwDatabase().getIconFactory();
|
PwIconFactory iconFactory = getPwDatabase().getIconFactory();
|
||||||
try {
|
try {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (getPwDatabase().getVersion()) {
|
||||||
case V3:
|
case V3:
|
||||||
cursor.populateEntry((PwEntryV3) pwEntry, iconFactory);
|
cursor.populateEntry((PwEntryV3) pwEntry, iconFactory);
|
||||||
|
break;
|
||||||
case V4:
|
case V4:
|
||||||
|
// TODO invert field reference manager
|
||||||
|
pwEntry.startToManageFieldReferences(getPwDatabase());
|
||||||
cursor.populateEntry((PwEntryV4) pwEntry, iconFactory);
|
cursor.populateEntry((PwEntryV4) pwEntry, iconFactory);
|
||||||
|
pwEntry.stopToManageFieldReferences();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of PwGroup can't be populated", e);
|
Log.e(TAG, "This version of PwGroup can't be populated", e);
|
||||||
}
|
}
|
||||||
pwEntry.stopToManageFieldReferences();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveData(Context ctx) throws IOException, PwDbOutputException {
|
public void saveData(Context ctx) throws IOException, PwDbOutputException {
|
||||||
@@ -515,18 +521,17 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PwEntry createEntry(@Nullable PwGroup parent) {
|
public PwEntry createEntry(@Nullable PwGroup parent) {
|
||||||
PwEntry newPwEntry = null;
|
|
||||||
try {
|
try {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (getPwDatabase().getVersion()) {
|
||||||
case V3:
|
case V3:
|
||||||
newPwEntry = new PwEntryV3((PwGroupV3) parent);
|
return new PwEntryV3((PwGroupV3) parent);
|
||||||
case V4:
|
case V4:
|
||||||
newPwEntry = new PwEntryV4((PwGroupV4) parent);
|
return new PwEntryV4((PwGroupV4) parent);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of PwEntry can't be created", e);
|
Log.e(TAG, "This version of PwEntry can't be created", e);
|
||||||
}
|
}
|
||||||
return newPwEntry;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwGroup createGroup(PwGroup parent) {
|
public PwGroup createGroup(PwGroup parent) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwGroupDB, PwEntryDB>,
|
public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwEntryDB>,
|
||||||
PwEntryDB extends PwEntry<PwGroupDB>> {
|
PwEntryDB extends PwEntry<PwGroupDB>> {
|
||||||
|
|
||||||
public static final UUID UUID_ZERO = new UUID(0,0);
|
public static final UUID UUID_ZERO = new UUID(0,0);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
|
|||||||
PwGroupV3 group = createGroup();
|
PwGroupV3 group = createGroup();
|
||||||
group.setId(newGroupId());
|
group.setId(newGroupId());
|
||||||
group.setName(name);
|
group.setName(name);
|
||||||
group.setIcon(iconFactory.getIcon(iconId));
|
group.setIconStandard(iconFactory.getIcon(iconId));
|
||||||
addGroupTo(group, parent);
|
addGroupTo(group, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
|
|||||||
*/
|
*/
|
||||||
for (int i = 0; i < entries.size(); i++) {
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
PwEntryV3 ent = entries.get(i);
|
PwEntryV3 ent = entries.get(i);
|
||||||
if (ent.getGroupId() == parent.getGroupId())
|
if (ent.getParent().getGroupId() == parent.getGroupId())
|
||||||
kids.add(ent);
|
kids.add(ent);
|
||||||
}
|
}
|
||||||
return kids;
|
return kids;
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
|
|||||||
private static final String PMS_ID_USER = "SYSTEM";
|
private static final String PMS_ID_USER = "SYSTEM";
|
||||||
private static final String PMS_ID_URL = "$";
|
private static final String PMS_ID_URL = "$";
|
||||||
|
|
||||||
// TODO Parent ID to remove
|
|
||||||
private int groupId;
|
|
||||||
private String title;
|
private String title;
|
||||||
private String username;
|
private String username;
|
||||||
private byte[] password;
|
private byte[] password;
|
||||||
@@ -94,12 +92,10 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
|
|||||||
|
|
||||||
public PwEntryV3(PwGroupV3 p) {
|
public PwEntryV3(PwGroupV3 p) {
|
||||||
construct(p);
|
construct(p);
|
||||||
groupId = ((PwGroupIdV3) this.parent.getId()).getId(); // TODO remove
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwEntryV3(Parcel in) {
|
public PwEntryV3(Parcel in) {
|
||||||
super(in);
|
super(in);
|
||||||
groupId = in.readInt();
|
|
||||||
title = in.readString();
|
title = in.readString();
|
||||||
username = in.readString();
|
username = in.readString();
|
||||||
in.readByteArray(password);
|
in.readByteArray(password);
|
||||||
@@ -112,7 +108,6 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
|
|||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
super.writeToParcel(dest, flags);
|
super.writeToParcel(dest, flags);
|
||||||
dest.writeInt(groupId);
|
|
||||||
dest.writeString(title);
|
dest.writeString(title);
|
||||||
dest.writeString(username);
|
dest.writeString(username);
|
||||||
dest.writeByteArray(password);
|
dest.writeByteArray(password);
|
||||||
@@ -136,7 +131,6 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
|
|||||||
|
|
||||||
protected void updateWith(PwEntryV3 source) {
|
protected void updateWith(PwEntryV3 source) {
|
||||||
super.assign(source);
|
super.assign(source);
|
||||||
groupId = source.groupId;
|
|
||||||
|
|
||||||
title = source.title;
|
title = source.title;
|
||||||
username = source.username;
|
username = source.username;
|
||||||
@@ -182,12 +176,9 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
|
|||||||
return newEntry;
|
return newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGroupId() {
|
|
||||||
return groupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGroupId(int groupId) {
|
public void setGroupId(int groupId) {
|
||||||
this.groupId = groupId;
|
this.parent = new PwGroupV3();
|
||||||
|
this.parent.setGroupId(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
|||||||
parentGroupLastMod = in.readParcelable(PwDate.class.getClassLoader());
|
parentGroupLastMod = in.readParcelable(PwDate.class.getClassLoader());
|
||||||
customData = MemUtil.readStringParcelableMap(in);
|
customData = MemUtil.readStringParcelableMap(in);
|
||||||
fields = in.readParcelable(ExtraFields.class.getClassLoader());
|
fields = in.readParcelable(ExtraFields.class.getClassLoader());
|
||||||
binaries = MemUtil.readStringParcelableMap(in, ProtectedBinary.class);
|
// TODO binaries takes too much memory for parcelable
|
||||||
|
// binaries = MemUtil.readStringParcelableMap(in, ProtectedBinary.class);
|
||||||
foregroundColor = in.readString();
|
foregroundColor = in.readString();
|
||||||
backgroupColor = in.readString();
|
backgroupColor = in.readString();
|
||||||
overrideURL = in.readString();
|
overrideURL = in.readString();
|
||||||
@@ -112,7 +113,7 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
|||||||
dest.writeParcelable(parentGroupLastMod, flags);
|
dest.writeParcelable(parentGroupLastMod, flags);
|
||||||
MemUtil.writeStringParcelableMap(dest, customData);
|
MemUtil.writeStringParcelableMap(dest, customData);
|
||||||
dest.writeParcelable(fields, flags);
|
dest.writeParcelable(fields, flags);
|
||||||
MemUtil.writeStringParcelableMap(dest, flags, binaries);
|
// TODO MemUtil.writeStringParcelableMap(dest, flags, binaries);
|
||||||
dest.writeString(foregroundColor);
|
dest.writeString(foregroundColor);
|
||||||
dest.writeString(backgroupColor);
|
dest.writeString(backgroupColor);
|
||||||
dest.writeString(overrideURL);
|
dest.writeString(overrideURL);
|
||||||
@@ -241,14 +242,6 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
|||||||
fields.putProtectedString(key, value, protect);
|
fields.putProtectedString(key, value, protect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwIconCustom getCustomIcon() {
|
|
||||||
return customIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCustomIcon(PwIconCustom icon) {
|
|
||||||
this.customIcon = icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PwDate getLocationChanged() {
|
public PwDate getLocationChanged() {
|
||||||
return parentGroupLastMod;
|
return parentGroupLastMod;
|
||||||
}
|
}
|
||||||
@@ -275,15 +268,28 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
|||||||
return decodeRefKey(mDecodeRef, STR_URL);
|
return decodeRefKey(mDecodeRef, STR_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PwIcon getIcon() {
|
public PwIcon getIcon() {
|
||||||
if (customIcon == null || customIcon.getUUID().equals(PwDatabase.UUID_ZERO)) {
|
if (customIcon == null || customIcon.isUnknown()) {
|
||||||
return super.getIcon();
|
return super.getIcon();
|
||||||
} else {
|
} else {
|
||||||
return customIcon;
|
return customIcon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIconCustom(PwIconCustom icon) {
|
||||||
|
this.customIcon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PwIconCustom getIconCustom() {
|
||||||
|
return customIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIconStandard(PwIconStandard icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
this.customIcon = PwIconCustom.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean allowExtraFields() {
|
public boolean allowExtraFields() {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ import android.os.Parcel;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup, ChildEntry extends PwEntry>
|
public abstract class PwGroup<GroupG extends PwGroup, EntryE extends PwEntry>
|
||||||
extends PwNode<Parent> {
|
extends PwNode<GroupG> {
|
||||||
|
|
||||||
protected String name = "";
|
protected String name = "";
|
||||||
|
|
||||||
// TODO verify children not needed
|
// TODO verify children not needed
|
||||||
transient protected List<ChildGroup> childGroups = new ArrayList<>();
|
transient protected List<GroupG> childGroups = new ArrayList<>();
|
||||||
transient protected List<ChildEntry> childEntries = new ArrayList<>();
|
transient protected List<EntryE> childEntries = new ArrayList<>();
|
||||||
|
|
||||||
protected PwGroup() {
|
protected PwGroup() {
|
||||||
super();
|
super();
|
||||||
@@ -54,48 +54,48 @@ public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup
|
|||||||
return (PwGroup) super.clone();
|
return (PwGroup) super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assign(PwGroup<Parent, ChildGroup, ChildEntry> source) {
|
protected void assign(PwGroup<GroupG, EntryE> source) {
|
||||||
super.assign(source);
|
super.assign(source);
|
||||||
name = source.name;
|
name = source.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ChildGroup> getChildGroups() {
|
public List<GroupG> getChildGroups() {
|
||||||
return childGroups;
|
return childGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ChildEntry> getChildEntries() {
|
public List<EntryE> getChildEntries() {
|
||||||
return childEntries;
|
return childEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroups(List<ChildGroup> groups) {
|
public void setGroups(List<GroupG> groups) {
|
||||||
childGroups = groups;
|
childGroups = groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntries(List<ChildEntry> entries) {
|
public void setEntries(List<EntryE> entries) {
|
||||||
childEntries = entries;
|
childEntries = entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChildGroup(ChildGroup group) {
|
public void addChildGroup(GroupG group) {
|
||||||
this.childGroups.add(group);
|
this.childGroups.add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChildEntry(ChildEntry entry) {
|
public void addChildEntry(EntryE entry) {
|
||||||
this.childEntries.add(entry);
|
this.childEntries.add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChildGroup getChildGroupAt(int number) {
|
public GroupG getChildGroupAt(int number) {
|
||||||
return this.childGroups.get(number);
|
return this.childGroups.get(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChildEntry getChildEntryAt(int number) {
|
public EntryE getChildEntryAt(int number) {
|
||||||
return this.childEntries.get(number);
|
return this.childEntries.get(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeChildGroup(ChildGroup group) {
|
public void removeChildGroup(GroupG group) {
|
||||||
this.childGroups.remove(group);
|
this.childGroups.remove(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeChildEntry(ChildEntry entry) {
|
public void removeChildEntry(EntryE entry) {
|
||||||
this.childEntries.remove(entry);
|
this.childEntries.remove(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup
|
|||||||
public List<PwNode> getDirectChildren() {
|
public List<PwNode> getDirectChildren() {
|
||||||
List<PwNode> children = new ArrayList<>();
|
List<PwNode> children = new ArrayList<>();
|
||||||
children.addAll(childGroups);
|
children.addAll(childGroups);
|
||||||
for(ChildEntry child : childEntries) {
|
for(EntryE child : childEntries) {
|
||||||
if (!child.isMetaStream())
|
if (!child.isMetaStream())
|
||||||
children.add(child);
|
children.add(child);
|
||||||
}
|
}
|
||||||
@@ -154,15 +154,15 @@ public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean preOrderTraverseTree(GroupHandler<ChildGroup> groupHandler,
|
public boolean preOrderTraverseTree(GroupHandler<GroupG> groupHandler,
|
||||||
EntryHandler<ChildEntry> entryHandler) {
|
EntryHandler<EntryE> entryHandler) {
|
||||||
if (entryHandler != null) {
|
if (entryHandler != null) {
|
||||||
for (ChildEntry entry : childEntries) {
|
for (EntryE entry : childEntries) {
|
||||||
if (!entryHandler.operate(entry)) return false;
|
if (!entryHandler.operate(entry)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ChildGroup group : childGroups) {
|
for (GroupG group : childGroups) {
|
||||||
if ((groupHandler != null) && !groupHandler.operate(group)) return false;
|
if ((groupHandler != null) && !groupHandler.operate(group)) return false;
|
||||||
group.preOrderTraverseTree(groupHandler, entryHandler);
|
group.preOrderTraverseTree(groupHandler, entryHandler);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package com.kunzisoft.keepass.database;
|
|||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
|
||||||
public class PwGroupV3 extends PwGroup<PwGroupV3, PwGroupV3, PwEntryV3> {
|
public class PwGroupV3 extends PwGroup<PwGroupV3, PwEntryV3> {
|
||||||
|
|
||||||
// for tree traversing
|
// for tree traversing
|
||||||
private int groupId;
|
private int groupId;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implements ITimeLogger {
|
public class PwGroupV4 extends PwGroup<PwGroupV4, PwEntryV4> implements ITimeLogger {
|
||||||
|
|
||||||
public static final boolean DEFAULT_SEARCHING_ENABLED = true;
|
public static final boolean DEFAULT_SEARCHING_ENABLED = true;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
|
|||||||
customIcon = in.readParcelable(PwIconCustom.class.getClassLoader());
|
customIcon = in.readParcelable(PwIconCustom.class.getClassLoader());
|
||||||
usageCount = in.readLong();
|
usageCount = in.readLong();
|
||||||
parentGroupLastMod = in.readParcelable(PwDate.class.getClassLoader());
|
parentGroupLastMod = in.readParcelable(PwDate.class.getClassLoader());
|
||||||
customData = MemUtil.readStringParcelableMap(in);
|
// TODO customData = MemUtil.readStringParcelableMap(in);
|
||||||
expires = in.readByte() != 0;
|
expires = in.readByte() != 0;
|
||||||
notes = in.readString();
|
notes = in.readString();
|
||||||
isExpanded = in.readByte() != 0;
|
isExpanded = in.readByte() != 0;
|
||||||
@@ -84,7 +84,7 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
|
|||||||
dest.writeParcelable(customIcon, flags);
|
dest.writeParcelable(customIcon, flags);
|
||||||
dest.writeLong(usageCount);
|
dest.writeLong(usageCount);
|
||||||
dest.writeParcelable(parentGroupLastMod, flags);
|
dest.writeParcelable(parentGroupLastMod, flags);
|
||||||
MemUtil.writeStringParcelableMap(dest, customData);
|
// TODO MemUtil.writeStringParcelableMap(dest, customData);
|
||||||
dest.writeByte((byte) (expires ? 1 : 0));
|
dest.writeByte((byte) (expires ? 1 : 0));
|
||||||
dest.writeString(notes);
|
dest.writeString(notes);
|
||||||
dest.writeByte((byte) (isExpanded ? 1 : 0));
|
dest.writeByte((byte) (isExpanded ? 1 : 0));
|
||||||
@@ -169,14 +169,6 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
|
|||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwIconCustom getCustomIcon() {
|
|
||||||
return customIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCustomIcon(PwIconCustom icon) {
|
|
||||||
this.customIcon = icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PwGroupId getId() {
|
public PwGroupId getId() {
|
||||||
return new PwGroupIdV4(uuid);
|
return new PwGroupIdV4(uuid);
|
||||||
@@ -232,6 +224,19 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PwIconCustom getIconCustom() {
|
||||||
|
return customIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIconCustom(PwIconCustom icon) {
|
||||||
|
this.customIcon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIconStandard(PwIconStandard icon) { // TODO Encapsulate with PwEntryV4
|
||||||
|
this.icon = icon;
|
||||||
|
this.customIcon = PwIconCustom.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
public void putCustomData(String key, String value) {
|
public void putCustomData(String key, String value) {
|
||||||
customData.put(key, value);
|
customData.put(key, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class PwIconCustom extends PwIcon {
|
|||||||
public static final PwIconCustom ZERO = new PwIconCustom(PwDatabase.UUID_ZERO, new byte[0]);
|
public static final PwIconCustom ZERO = new PwIconCustom(PwDatabase.UUID_ZERO, new byte[0]);
|
||||||
|
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private byte[] imageData;
|
transient private byte[] imageData;
|
||||||
|
|
||||||
public PwIconCustom(UUID uuid, byte[] data) {
|
public PwIconCustom(UUID uuid, byte[] data) {
|
||||||
super();
|
super();
|
||||||
@@ -44,7 +44,8 @@ public class PwIconCustom extends PwIcon {
|
|||||||
protected PwIconCustom(Parcel in) {
|
protected PwIconCustom(Parcel in) {
|
||||||
super(in);
|
super(in);
|
||||||
uuid = (UUID) in.readSerializable();
|
uuid = (UUID) in.readSerializable();
|
||||||
in.readByteArray(imageData);
|
// TODO Take too much memories
|
||||||
|
// in.readByteArray(imageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -67,7 +68,7 @@ public class PwIconCustom extends PwIcon {
|
|||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeSerializable(uuid);
|
dest.writeSerializable(uuid);
|
||||||
dest.writeByteArray(imageData);
|
// Too big for a parcelable dest.writeByteArray(imageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<PwIconCustom> CREATOR = new Creator<PwIconCustom>() {
|
public static final Creator<PwIconCustom> CREATOR = new Creator<PwIconCustom>() {
|
||||||
@@ -82,7 +83,7 @@ public class PwIconCustom extends PwIcon {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ public class PwIconFactory {
|
|||||||
*/
|
*/
|
||||||
private ReferenceMap customCache = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK);
|
private ReferenceMap customCache = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK);
|
||||||
|
|
||||||
|
public PwIconStandard getUnknownIcon() {
|
||||||
|
return getIcon(PwIconStandard.UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
public PwIconStandard getKeyIcon() {
|
public PwIconStandard getKeyIcon() {
|
||||||
return getIcon(PwIconStandard.KEY);
|
return getIcon(PwIconStandard.KEY);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,14 +132,14 @@ public abstract class PwNode<Parent extends PwGroup> implements ISmallTimeLogger
|
|||||||
* @return Visual icon
|
* @return Visual icon
|
||||||
*/
|
*/
|
||||||
public PwIcon getIcon() {
|
public PwIcon getIcon() {
|
||||||
return icon;
|
return getIconStandard();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwIconStandard getIconStandard() {
|
public PwIconStandard getIconStandard() {
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIcon(PwIconStandard icon) {
|
public void setIconStandard(PwIconStandard icon) {
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,15 +31,15 @@ import java.util.List;
|
|||||||
|
|
||||||
public class DeleteGroupRunnable extends ActionNodeDatabaseRunnable {
|
public class DeleteGroupRunnable extends ActionNodeDatabaseRunnable {
|
||||||
|
|
||||||
private PwGroup<PwGroup, PwGroup, PwEntry> mGroupToDelete;
|
private PwGroup<PwGroup, PwEntry> mGroupToDelete;
|
||||||
private PwGroup mParent;
|
private PwGroup mParent;
|
||||||
private boolean mRecycle;
|
private boolean mRecycle;
|
||||||
|
|
||||||
public DeleteGroupRunnable(Context ctx, Database db, PwGroup<PwGroup, PwGroup, PwEntry> group, AfterActionNodeOnFinish finish) {
|
public DeleteGroupRunnable(Context ctx, Database db, PwGroup<PwGroup, PwEntry> group, AfterActionNodeOnFinish finish) {
|
||||||
this(ctx, db, group, finish, false);
|
this(ctx, db, group, finish, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteGroupRunnable(Context ctx, Database db, PwGroup<PwGroup, PwGroup, PwEntry> group, AfterActionNodeOnFinish finish, boolean dontSave) {
|
public DeleteGroupRunnable(Context ctx, Database db, PwGroup<PwGroup, PwEntry> group, AfterActionNodeOnFinish finish, boolean dontSave) {
|
||||||
super(ctx, db, finish, dontSave);
|
super(ctx, db, finish, dontSave);
|
||||||
mGroupToDelete = group;
|
mGroupToDelete = group;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ public class EntryCursor extends MatrixCursor {
|
|||||||
entry.getUUID().getLeastSignificantBits(),
|
entry.getUUID().getLeastSignificantBits(),
|
||||||
entry.getTitle(),
|
entry.getTitle(),
|
||||||
entry.getIconStandard().getIconId(),
|
entry.getIconStandard().getIconId(),
|
||||||
entry.getCustomIcon().getUUID().getMostSignificantBits(),
|
entry.getIconCustom().getUUID().getMostSignificantBits(),
|
||||||
entry.getCustomIcon().getUUID().getLeastSignificantBits(),
|
entry.getIconCustom().getUUID().getLeastSignificantBits(),
|
||||||
entry.getUsername(),
|
entry.getUsername(),
|
||||||
entry.getPassword(),
|
entry.getPassword(),
|
||||||
entry.getUrl(),
|
entry.getUrl(),
|
||||||
@@ -88,7 +88,7 @@ public class EntryCursor extends MatrixCursor {
|
|||||||
pwEntry.setTitle(getString(getColumnIndex(EntryCursor.COLUMN_INDEX_TITLE)));
|
pwEntry.setTitle(getString(getColumnIndex(EntryCursor.COLUMN_INDEX_TITLE)));
|
||||||
|
|
||||||
PwIconStandard iconStandard = iconFactory.getIcon(getInt(getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_STANDARD)));
|
PwIconStandard iconStandard = iconFactory.getIcon(getInt(getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_STANDARD)));
|
||||||
pwEntry.setIcon(iconStandard);
|
pwEntry.setIconStandard(iconStandard);
|
||||||
|
|
||||||
pwEntry.setUsername(getString(getColumnIndex(EntryCursor.COLUMN_INDEX_USERNAME)));
|
pwEntry.setUsername(getString(getColumnIndex(EntryCursor.COLUMN_INDEX_USERNAME)));
|
||||||
pwEntry.setPassword(getString(getColumnIndex(EntryCursor.COLUMN_INDEX_PASSWORD)));
|
pwEntry.setPassword(getString(getColumnIndex(EntryCursor.COLUMN_INDEX_PASSWORD)));
|
||||||
@@ -107,7 +107,7 @@ public class EntryCursor extends MatrixCursor {
|
|||||||
PwIconCustom iconCustom = iconFactory.getIcon(
|
PwIconCustom iconCustom = iconFactory.getIcon(
|
||||||
new UUID(getLong(getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_MOST_SIGNIFICANT_BITS)),
|
new UUID(getLong(getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_MOST_SIGNIFICANT_BITS)),
|
||||||
getLong(getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_LEAST_SIGNIFICANT_BITS))));
|
getLong(getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_LEAST_SIGNIFICANT_BITS))));
|
||||||
pwEntry.setCustomIcon(iconCustom);
|
pwEntry.setIconCustom(iconCustom);
|
||||||
|
|
||||||
// Retrieve extra fields
|
// Retrieve extra fields
|
||||||
if (extraFieldCursor.moveToFirst()) {
|
if (extraFieldCursor.moveToFirst()) {
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ public class ImporterV3 extends Importer {
|
|||||||
grp.setExpiryTime(new PwDate(buf, offset));
|
grp.setExpiryTime(new PwDate(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0007 :
|
case 0x0007 :
|
||||||
grp.setIcon(db.getIconFactory().getIcon(LEDataInputStream.readInt(buf, offset)));
|
grp.setIconStandard(db.getIconFactory().getIcon(LEDataInputStream.readInt(buf, offset)));
|
||||||
break;
|
break;
|
||||||
case 0x0008 :
|
case 0x0008 :
|
||||||
grp.setLevel(LEDataInputStream.readUShort(buf, offset));
|
grp.setLevel(LEDataInputStream.readUShort(buf, offset));
|
||||||
@@ -353,7 +353,7 @@ public class ImporterV3 extends Importer {
|
|||||||
iconId = 0;
|
iconId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ent.setIcon(db.getIconFactory().getIcon(iconId));
|
ent.setIconStandard(db.getIconFactory().getIcon(iconId));
|
||||||
break;
|
break;
|
||||||
case 0x0004 :
|
case 0x0004 :
|
||||||
ent.setTitle(Types.readCString(buf, offset));
|
ent.setTitle(Types.readCString(buf, offset));
|
||||||
|
|||||||
@@ -556,9 +556,9 @@ public class ImporterV4 extends Importer {
|
|||||||
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemNotes) ) {
|
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemNotes) ) {
|
||||||
ctxGroup.setNotes(ReadString(xpp));
|
ctxGroup.setNotes(ReadString(xpp));
|
||||||
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemIcon) ) {
|
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemIcon) ) {
|
||||||
ctxGroup.setIcon(db.getIconFactory().getIcon((int)ReadUInt(xpp, 0)));
|
ctxGroup.setIconStandard(db.getIconFactory().getIcon((int)ReadUInt(xpp, 0)));
|
||||||
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemCustomIconID) ) {
|
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemCustomIconID) ) {
|
||||||
ctxGroup.setCustomIcon(db.getIconFactory().getIcon(ReadUuid(xpp)));
|
ctxGroup.setIconCustom(db.getIconFactory().getIcon(ReadUuid(xpp)));
|
||||||
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemTimes) ) {
|
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemTimes) ) {
|
||||||
return SwitchContext(ctx, KdbContext.GroupTimes, xpp);
|
return SwitchContext(ctx, KdbContext.GroupTimes, xpp);
|
||||||
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemIsExpanded) ) {
|
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemIsExpanded) ) {
|
||||||
@@ -611,9 +611,9 @@ public class ImporterV4 extends Importer {
|
|||||||
if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemUuid) ) {
|
if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemUuid) ) {
|
||||||
ctxEntry.setUUID(ReadUuid(xpp));
|
ctxEntry.setUUID(ReadUuid(xpp));
|
||||||
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemIcon) ) {
|
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemIcon) ) {
|
||||||
ctxEntry.setIcon(db.getIconFactory().getIcon((int)ReadUInt(xpp, 0)));
|
ctxEntry.setIconStandard(db.getIconFactory().getIcon((int)ReadUInt(xpp, 0)));
|
||||||
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemCustomIconID) ) {
|
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemCustomIconID) ) {
|
||||||
ctxEntry.setCustomIcon(db.getIconFactory().getIcon(ReadUuid(xpp)));
|
ctxEntry.setIconCustom(db.getIconFactory().getIcon(ReadUuid(xpp)));
|
||||||
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemFgColor) ) {
|
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemFgColor) ) {
|
||||||
ctxEntry.setForegroundColor(ReadString(xpp));
|
ctxEntry.setForegroundColor(ReadString(xpp));
|
||||||
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemBgColor) ) {
|
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemBgColor) ) {
|
||||||
|
|||||||
@@ -352,8 +352,8 @@ public class PwDbV4Output extends PwDbOutput<PwDbHeaderV4> {
|
|||||||
writeObject(PwDatabaseV4XML.ElemNotes, group.getNotes());
|
writeObject(PwDatabaseV4XML.ElemNotes, group.getNotes());
|
||||||
writeObject(PwDatabaseV4XML.ElemIcon, group.getIconStandard().getIconId());
|
writeObject(PwDatabaseV4XML.ElemIcon, group.getIconStandard().getIconId());
|
||||||
|
|
||||||
if (!group.getCustomIcon().equals(PwIconCustom.ZERO)) {
|
if (!group.getIconCustom().equals(PwIconCustom.ZERO)) {
|
||||||
writeObject(PwDatabaseV4XML.ElemCustomIconID, group.getCustomIcon().getUUID());
|
writeObject(PwDatabaseV4XML.ElemCustomIconID, group.getIconCustom().getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
writeList(PwDatabaseV4XML.ElemTimes, group);
|
writeList(PwDatabaseV4XML.ElemTimes, group);
|
||||||
@@ -377,8 +377,8 @@ public class PwDbV4Output extends PwDbOutput<PwDbHeaderV4> {
|
|||||||
writeObject(PwDatabaseV4XML.ElemUuid, entry.getUUID());
|
writeObject(PwDatabaseV4XML.ElemUuid, entry.getUUID());
|
||||||
writeObject(PwDatabaseV4XML.ElemIcon, entry.getIconStandard().getIconId());
|
writeObject(PwDatabaseV4XML.ElemIcon, entry.getIconStandard().getIconId());
|
||||||
|
|
||||||
if (!entry.getCustomIcon().equals(PwIconCustom.ZERO)) {
|
if (!entry.getIconCustom().equals(PwIconCustom.ZERO)) {
|
||||||
writeObject(PwDatabaseV4XML.ElemCustomIconID, entry.getCustomIcon().getUUID());
|
writeObject(PwDatabaseV4XML.ElemCustomIconID, entry.getIconCustom().getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
writeObject(PwDatabaseV4XML.ElemFgColor, entry.getForegroundColor());
|
writeObject(PwDatabaseV4XML.ElemFgColor, entry.getForegroundColor());
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class PwEntryOutputV3 {
|
|||||||
// Group ID
|
// Group ID
|
||||||
mOS.write(GROUPID_FIELD_TYPE);
|
mOS.write(GROUPID_FIELD_TYPE);
|
||||||
mOS.write(LONG_FOUR);
|
mOS.write(LONG_FOUR);
|
||||||
mOS.write(LEDataOutputStream.writeIntBuf(mPE.getGroupId()));
|
mOS.write(LEDataOutputStream.writeIntBuf(mPE.getParent().getGroupId()));
|
||||||
|
|
||||||
// Image ID
|
// Image ID
|
||||||
mOS.write(IMAGEID_FIELD_TYPE);
|
mOS.write(IMAGEID_FIELD_TYPE);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import java.util.Locale;
|
|||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
public class SearchDbHelper<PwDatabaseVersion extends PwDatabase<PwGroupSearch, PwEntrySearch>,
|
public class SearchDbHelper<PwDatabaseVersion extends PwDatabase<PwGroupSearch, PwEntrySearch>,
|
||||||
PwGroupSearch extends PwGroup<PwGroupSearch, PwGroupSearch, PwEntrySearch>,
|
PwGroupSearch extends PwGroup<PwGroupSearch, PwEntrySearch>,
|
||||||
PwEntrySearch extends PwEntry<PwGroupSearch>> {
|
PwEntrySearch extends PwEntry<PwGroupSearch>> {
|
||||||
|
|
||||||
private final Context mCtx;
|
private final Context mCtx;
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.kunzisoft.keepass.R;
|
import com.kunzisoft.keepass.R;
|
||||||
import com.kunzisoft.keepass.app.App;
|
import com.kunzisoft.keepass.app.App;
|
||||||
|
import com.kunzisoft.keepass.database.Database;
|
||||||
import com.kunzisoft.keepass.database.PwGroup;
|
import com.kunzisoft.keepass.database.PwGroup;
|
||||||
import com.kunzisoft.keepass.database.PwIcon;
|
import com.kunzisoft.keepass.database.PwIcon;
|
||||||
import com.kunzisoft.keepass.icons.IconPackChooser;
|
|
||||||
|
|
||||||
import static com.kunzisoft.keepass.dialogs.GroupEditDialogFragment.EditGroupDialogAction.CREATION;
|
import static com.kunzisoft.keepass.dialogs.GroupEditDialogFragment.EditGroupDialogAction.CREATION;
|
||||||
import static com.kunzisoft.keepass.dialogs.GroupEditDialogFragment.EditGroupDialogAction.UPDATE;
|
import static com.kunzisoft.keepass.dialogs.GroupEditDialogFragment.EditGroupDialogAction.UPDATE;
|
||||||
@@ -49,9 +49,11 @@ public class GroupEditDialogFragment extends DialogFragment
|
|||||||
public static final String TAG_CREATE_GROUP = "TAG_CREATE_GROUP";
|
public static final String TAG_CREATE_GROUP = "TAG_CREATE_GROUP";
|
||||||
|
|
||||||
public static final String KEY_NAME = "KEY_NAME";
|
public static final String KEY_NAME = "KEY_NAME";
|
||||||
public static final String KEY_ICON_ID = "KEY_ICON_ID";
|
public static final String KEY_ICON = "KEY_ICON";
|
||||||
public static final String KEY_ACTION_ID = "KEY_ACTION_ID";
|
public static final String KEY_ACTION_ID = "KEY_ACTION_ID";
|
||||||
|
|
||||||
|
private Database database;
|
||||||
|
|
||||||
private EditGroupListener editGroupListener;
|
private EditGroupListener editGroupListener;
|
||||||
|
|
||||||
private EditGroupDialogAction editGroupDialogAction;
|
private EditGroupDialogAction editGroupDialogAction;
|
||||||
@@ -59,6 +61,7 @@ public class GroupEditDialogFragment extends DialogFragment
|
|||||||
private PwIcon iconGroup;
|
private PwIcon iconGroup;
|
||||||
|
|
||||||
private ImageView iconButton;
|
private ImageView iconButton;
|
||||||
|
private int iconColor;
|
||||||
|
|
||||||
public enum EditGroupDialogAction {
|
public enum EditGroupDialogAction {
|
||||||
CREATION, UPDATE, NONE;
|
CREATION, UPDATE, NONE;
|
||||||
@@ -79,7 +82,7 @@ public class GroupEditDialogFragment extends DialogFragment
|
|||||||
public static GroupEditDialogFragment build(PwGroup group) {
|
public static GroupEditDialogFragment build(PwGroup group) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(KEY_NAME, group.getName());
|
bundle.putString(KEY_NAME, group.getName());
|
||||||
bundle.putParcelable(KEY_ICON_ID, group.getIcon());
|
bundle.putParcelable(KEY_ICON, group.getIcon());
|
||||||
bundle.putInt(KEY_ACTION_ID, UPDATE.ordinal());
|
bundle.putInt(KEY_ACTION_ID, UPDATE.ordinal());
|
||||||
GroupEditDialogFragment fragment = new GroupEditDialogFragment();
|
GroupEditDialogFragment fragment = new GroupEditDialogFragment();
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
@@ -112,20 +115,21 @@ public class GroupEditDialogFragment extends DialogFragment
|
|||||||
// Retrieve the textColor to tint the icon
|
// Retrieve the textColor to tint the icon
|
||||||
int[] attrs = {android.R.attr.textColorPrimary};
|
int[] attrs = {android.R.attr.textColorPrimary};
|
||||||
TypedArray ta = getActivity().getTheme().obtainStyledAttributes(attrs);
|
TypedArray ta = getActivity().getTheme().obtainStyledAttributes(attrs);
|
||||||
int iconColor = ta.getColor(0, Color.WHITE);
|
iconColor = ta.getColor(0, Color.WHITE);
|
||||||
|
|
||||||
// Init elements
|
// Init elements
|
||||||
|
database = App.getDB();
|
||||||
editGroupDialogAction = EditGroupDialogAction.NONE;
|
editGroupDialogAction = EditGroupDialogAction.NONE;
|
||||||
nameGroup = "";
|
nameGroup = "";
|
||||||
iconGroup = App.getDB().getPwDatabase().getIconFactory().getFolderIcon();
|
iconGroup = database.getPwDatabase().getIconFactory().getFolderIcon();
|
||||||
|
|
||||||
if (savedInstanceState != null
|
if (savedInstanceState != null
|
||||||
&& savedInstanceState.containsKey(KEY_ACTION_ID)
|
&& savedInstanceState.containsKey(KEY_ACTION_ID)
|
||||||
&& savedInstanceState.containsKey(KEY_NAME)
|
&& savedInstanceState.containsKey(KEY_NAME)
|
||||||
&& savedInstanceState.containsKey(KEY_ICON_ID)) {
|
&& savedInstanceState.containsKey(KEY_ICON)) {
|
||||||
editGroupDialogAction = getActionFromOrdinal(savedInstanceState.getInt(KEY_ACTION_ID));
|
editGroupDialogAction = getActionFromOrdinal(savedInstanceState.getInt(KEY_ACTION_ID));
|
||||||
nameGroup = savedInstanceState.getString(KEY_NAME);
|
nameGroup = savedInstanceState.getString(KEY_NAME);
|
||||||
iconGroup = savedInstanceState.getParcelable(KEY_ICON_ID);
|
iconGroup = savedInstanceState.getParcelable(KEY_ICON);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -135,30 +139,16 @@ public class GroupEditDialogFragment extends DialogFragment
|
|||||||
|
|
||||||
if (getArguments() != null
|
if (getArguments() != null
|
||||||
&& getArguments().containsKey(KEY_NAME)
|
&& getArguments().containsKey(KEY_NAME)
|
||||||
&& getArguments().containsKey(KEY_ICON_ID)) {
|
&& getArguments().containsKey(KEY_ICON)) {
|
||||||
nameGroup = getArguments().getString(KEY_NAME);
|
nameGroup = getArguments().getString(KEY_NAME);
|
||||||
iconGroup = getArguments().getParcelable(KEY_ICON_ID);
|
iconGroup = getArguments().getParcelable(KEY_ICON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// populate the name
|
// populate the name
|
||||||
nameField.setText(nameGroup);
|
nameField.setText(nameGroup);
|
||||||
// populate the icon
|
// populate the icon
|
||||||
if (IconPackChooser.getSelectedIconPack(getContext()).tintable()) {
|
assignIconView();
|
||||||
App.getDB().getDrawFactory()
|
|
||||||
.assignDatabaseIconTo(
|
|
||||||
getContext(),
|
|
||||||
iconButton,
|
|
||||||
iconGroup,
|
|
||||||
true,
|
|
||||||
iconColor);
|
|
||||||
} else {
|
|
||||||
App.getDB().getDrawFactory()
|
|
||||||
.assignDatabaseIconTo(
|
|
||||||
getContext(),
|
|
||||||
iconButton,
|
|
||||||
iconGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setView(root)
|
builder.setView(root)
|
||||||
@@ -195,18 +185,26 @@ public class GroupEditDialogFragment extends DialogFragment
|
|||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assignIconView() {
|
||||||
|
database.getDrawFactory()
|
||||||
|
.assignDatabaseIconTo(
|
||||||
|
getContext(),
|
||||||
|
iconButton,
|
||||||
|
iconGroup,
|
||||||
|
iconColor);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void iconPicked(Bundle bundle) {
|
public void iconPicked(Bundle bundle) {
|
||||||
int selectedIconID = bundle.getInt(IconPickerDialogFragment.KEY_ICON_ID);
|
iconGroup = bundle.getParcelable(IconPickerDialogFragment.KEY_ICON_STANDARD);
|
||||||
iconButton.setImageResource(IconPackChooser.getSelectedIconPack(getContext()).iconToResId(selectedIconID));
|
assignIconView();
|
||||||
iconGroup = App.getDB().getPwDatabase().getIconFactory().getIcon(selectedIconID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
outState.putInt(KEY_ACTION_ID, editGroupDialogAction.ordinal());
|
outState.putInt(KEY_ACTION_ID, editGroupDialogAction.ordinal());
|
||||||
outState.putString(KEY_NAME, nameGroup);
|
outState.putString(KEY_NAME, nameGroup);
|
||||||
outState.putParcelable(KEY_ICON_ID, iconGroup);
|
outState.putParcelable(KEY_ICON, iconGroup);
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,14 +37,16 @@ import android.widget.GridView;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.kunzisoft.keepass.R;
|
import com.kunzisoft.keepass.R;
|
||||||
|
import com.kunzisoft.keepass.database.PwIconStandard;
|
||||||
import com.kunzisoft.keepass.icons.IconPack;
|
import com.kunzisoft.keepass.icons.IconPack;
|
||||||
import com.kunzisoft.keepass.icons.IconPackChooser;
|
import com.kunzisoft.keepass.icons.IconPackChooser;
|
||||||
import com.kunzisoft.keepass.stylish.StylishActivity;
|
import com.kunzisoft.keepass.stylish.StylishActivity;
|
||||||
|
|
||||||
|
|
||||||
public class IconPickerDialogFragment extends DialogFragment {
|
public class IconPickerDialogFragment extends DialogFragment {
|
||||||
public static final String KEY_ICON_ID = "icon_id";
|
|
||||||
public static final int UNDEFINED_ICON_ID = -1;
|
public static final String KEY_ICON_STANDARD = "KEY_ICON_STANDARD";
|
||||||
|
|
||||||
private IconPickerListener iconPickerListener;
|
private IconPickerListener iconPickerListener;
|
||||||
private IconPack iconPack;
|
private IconPack iconPack;
|
||||||
|
|
||||||
@@ -85,7 +87,7 @@ public class IconPickerDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
currIconGridView.setOnItemClickListener((parent, v, position, id) -> {
|
currIconGridView.setOnItemClickListener((parent, v, position, id) -> {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putInt(KEY_ICON_ID, position);
|
bundle.putParcelable(KEY_ICON_STANDARD, new PwIconStandard(position));
|
||||||
iconPickerListener.iconPicked(bundle);
|
iconPickerListener.iconPicked(bundle);
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -65,52 +65,50 @@ public class IconDrawableFactory {
|
|||||||
private ReferenceMap standardIconMap = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK);
|
private ReferenceMap standardIconMap = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign a default database icon to an ImageView
|
* Assign a default database icon to an ImageView and tint it if needed
|
||||||
*
|
*
|
||||||
* @param context Context to build the drawable
|
* @param context Context to build the drawable
|
||||||
* @param iv ImageView that will host the drawable
|
* @param iconView ImageView that will host the drawable
|
||||||
|
* @param tintColor Use this color to tint tintable icon
|
||||||
*/
|
*/
|
||||||
public void assignDefaultDatabaseIconTo(Context context, ImageView iv) {
|
public void assignDefaultDatabaseIconTo(Context context, ImageView iconView, int tintColor) {
|
||||||
assignDefaultDatabaseIconTo(context, iv, false, Color.WHITE);
|
if (IconPackChooser.getSelectedIconPack(context).tintable()) {
|
||||||
|
assignDrawableTo(context,
|
||||||
|
iconView,
|
||||||
|
IconPackChooser.getSelectedIconPack(context).getDefaultIconId(),
|
||||||
|
true,
|
||||||
|
tintColor);
|
||||||
|
} else {
|
||||||
|
assignDrawableTo(context,
|
||||||
|
iconView,
|
||||||
|
IconPackChooser.getSelectedIconPack(context).getDefaultIconId(),
|
||||||
|
false,
|
||||||
|
Color.WHITE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign a default database icon to an ImageView and tint it
|
* Assign a database icon to an ImageView and tint it if needed
|
||||||
*
|
*
|
||||||
* @param context Context to build the drawable
|
* @param context Context to build the drawable
|
||||||
* @param iv ImageView that will host the drawable
|
* @param iconView ImageView that will host the drawable
|
||||||
*/
|
|
||||||
public void assignDefaultDatabaseIconTo(Context context, ImageView iv, boolean tint, int tintColor) {
|
|
||||||
assignDrawableTo(context, iv, IconPackChooser.getSelectedIconPack(context).getDefaultIconId(), tint, tintColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Assign a database icon to an ImageView
|
|
||||||
*
|
|
||||||
* @param context Context to build the drawable
|
|
||||||
* @param iv ImageView that will host the drawable
|
|
||||||
* @param icon The icon from the database
|
* @param icon The icon from the database
|
||||||
|
* @param tintColor Use this color to tint tintable icon
|
||||||
*/
|
*/
|
||||||
public void assignDatabaseIconTo(Context context, ImageView iv, PwIcon icon) {
|
public void assignDatabaseIconTo(Context context, ImageView iconView, PwIcon icon, int tintColor) {
|
||||||
assignDatabaseIconTo(context, iv, icon, false, Color.WHITE);
|
if (IconPackChooser.getSelectedIconPack(context).tintable()) {
|
||||||
|
assignDrawableToImageView(getIconDrawable(context, icon, true, tintColor),
|
||||||
|
iconView,
|
||||||
|
true,
|
||||||
|
tintColor);
|
||||||
|
} else {
|
||||||
|
assignDrawableToImageView(getIconDrawable(context, icon, true, tintColor),
|
||||||
|
iconView,
|
||||||
|
false,
|
||||||
|
Color.WHITE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Assign a database icon to an ImageView and tint it
|
|
||||||
*
|
|
||||||
* @param context Context to build the drawable
|
|
||||||
* @param imageView ImageView that will host the drawable
|
|
||||||
* @param icon The icon from the database
|
|
||||||
* @param tint true will tint the drawable with tintColor
|
|
||||||
* @param tintColor Use this color if tint is true
|
|
||||||
*/
|
|
||||||
public void assignDatabaseIconTo(Context context, ImageView imageView, PwIcon icon, boolean tint, int tintColor) {
|
|
||||||
assignDrawableToImageView(getIconDrawable(context, icon, tint, tintColor),
|
|
||||||
imageView,
|
|
||||||
tint,
|
|
||||||
tintColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign an image by its resourceId to an ImageView and tint it
|
* Assign an image by its resourceId to an ImageView and tint it
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<string name="about_description">KeePass DX is an Android implementation of the KeePass password manager.</string>
|
<string name="about_description">KeePass DX is an Android implementation of the KeePass password manager.</string>
|
||||||
<string name="accept">Accept</string>
|
<string name="accept">Accept</string>
|
||||||
<string name="add_entry">Add entry</string>
|
<string name="add_entry">Add entry</string>
|
||||||
|
<string name="edit_entry">Edit entry</string>
|
||||||
<string name="add_group">Add group</string>
|
<string name="add_group">Add group</string>
|
||||||
<string name="add_string">Add string</string>
|
<string name="add_string">Add string</string>
|
||||||
<string name="encryption">Encryption</string>
|
<string name="encryption">Encryption</string>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
* New search in a single fragment
|
* New search in a single fragment
|
||||||
* Search suggestions
|
* Search suggestions
|
||||||
* Fix read-only mode
|
* Added the display of usernames
|
||||||
* Added translations
|
* Added translations
|
||||||
* Fix parcelable / toolbar
|
* Fix read-only mode
|
||||||
|
* Fix parcelable / toolbar / back
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
* Nouvelle recherche dans un seul fragment
|
* Nouvelle recherche dans un seul fragment
|
||||||
* Suggestions de recherche
|
* Suggestions de recherche
|
||||||
* Correction du mode lecture seule
|
* Ajout de l'affichage des noms d'utilisateurs
|
||||||
* Ajout de traductions
|
* Ajout de traductions
|
||||||
* Correction de parcelable / de barre de navigation
|
* Correction du mode lecture seule
|
||||||
|
* Correction de parcelable / barre de navigation / retour
|
||||||
Reference in New Issue
Block a user