Fix search / Fix icon - back #138 / Upgrade changelogs

This commit is contained in:
J-Jamet
2018-08-02 10:34:04 +02:00
parent 55dc504f26
commit cb5c324c9d
31 changed files with 261 additions and 245 deletions

View File

@@ -1,9 +1,10 @@
KeepassDX (2.5.0.0beta16)
* New search in a single fragment
* Search suggestions
* Fix read-only mode
* Added the display of usernames
* Added translations
* Fix parcelable / toolbar
* Fix read-only mode
* Fix parcelable / toolbar / back
KeepassDX (2.5.0.0beta15)
* Read only mode

View File

@@ -45,10 +45,10 @@ public class PwEntryTestV4 extends TestCase {
entry.setBackgroupColor("blue");
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.addToHistory(new PwEntryV4());
entry.setIcon(new PwIconStandard(5));
entry.setIconStandard(new PwIconStandard(5));
entry.setOverrideURL("override");
entry.setParent(new PwGroupV4());
entry.addExtraField("key2", new ProtectedString(false, "value2"));

View File

@@ -47,7 +47,6 @@ import com.kunzisoft.keepass.database.ExtraFields;
import com.kunzisoft.keepass.database.PwDatabase;
import com.kunzisoft.keepass.database.PwEntry;
import com.kunzisoft.keepass.database.security.ProtectedString;
import com.kunzisoft.keepass.icons.IconPackChooser;
import com.kunzisoft.keepass.lock.LockingActivity;
import com.kunzisoft.keepass.lock.LockingHideActivity;
import com.kunzisoft.keepass.notifications.NotificationCopyingService;
@@ -84,6 +83,8 @@ public class EntryActivity extends LockingHideActivity {
private ClipboardHelper clipboardHelper;
private boolean firstLaunchOfActivity;
private int iconColor;
public static void launch(Activity act, PwEntry pw, boolean readOnly) {
if (LockingActivity.checkTimeIsAllowedOrFinish(act)) {
Intent intent = new Intent(act, EntryActivity.class);
@@ -126,6 +127,11 @@ public class EntryActivity extends LockingHideActivity {
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
invalidateOptionsMenu();
@@ -312,15 +318,7 @@ public class EntryActivity extends LockingHideActivity {
mEntry.startToManageFieldReferences(pm);
// Assign title icon
if (IconPackChooser.getSelectedIconPack(this).tintable()) {
// 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());
}
db.getDrawFactory().assignDatabaseIconTo(this, titleIconView, mEntry.getIcon(), iconColor);
// Assign title text
titleView.setText(mEntry.getVisualTitle());

View File

@@ -56,7 +56,6 @@ import com.kunzisoft.keepass.database.action.node.UpdateEntryRunnable;
import com.kunzisoft.keepass.database.security.ProtectedString;
import com.kunzisoft.keepass.dialogs.GeneratePasswordDialogFragment;
import com.kunzisoft.keepass.dialogs.IconPickerDialogFragment;
import com.kunzisoft.keepass.icons.IconPackChooser;
import com.kunzisoft.keepass.lock.LockingActivity;
import com.kunzisoft.keepass.lock.LockingHideActivity;
import com.kunzisoft.keepass.settings.PreferencesUtil;
@@ -71,7 +70,7 @@ import java.util.UUID;
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
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 String ADD_OR_UPDATE_ENTRY_KEY = "ADD_OR_UPDATE_ENTRY_KEY";
private Database database;
protected PwEntry mEntry;
protected PwEntry mCallbackNewEntry;
protected boolean mIsNew;
protected int mSelectedIconID = UNDEFINED_ICON_ID;
protected PwIconStandard mSelectedIconStandard;
// Views
private ScrollView scrollView;
@@ -143,7 +144,6 @@ public class EntryEditActivity extends LockingHideActivity
setContentView(R.layout.entry_edit);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(getString(R.string.app_name));
setSupportActionBar(toolbar);
assert getSupportActionBar() != null;
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@@ -162,8 +162,8 @@ public class EntryEditActivity extends LockingHideActivity
entryExtraFieldsContainer = findViewById(R.id.advanced_container);
// Likely the app has been killed exit the activity
Database db = App.getDB();
if ( ! db.getLoaded() ) {
database = App.getDB();
if ( ! database.getLoaded() ) {
finish();
return;
}
@@ -176,18 +176,16 @@ public class EntryEditActivity extends LockingHideActivity
TypedArray ta = getTheme().obtainStyledAttributes(attrs);
iconColor = ta.getColor(0, Color.WHITE);
PwDatabase pm = db.getPwDatabase();
mSelectedIconStandard = database.getPwDatabase().getIconFactory().getUnknownIcon();
PwDatabase pm = database.getPwDatabase();
if ( uuidBytes == null ) {
PwGroupId parentId = intent.getParcelableExtra(KEY_PARENT);
PwGroup parent = pm.getGroupByGroupId(parentId);
mEntry = db.createEntry(parent);
mEntry = database.createEntry(parent);
mIsNew = true;
// Add the default icon
if (IconPackChooser.getSelectedIconPack(this).tintable()) {
App.getDB().getDrawFactory().assignDefaultDatabaseIconTo(this, entryIconView, true, iconColor);
} else {
App.getDB().getDrawFactory().assignDefaultDatabaseIconTo(this, entryIconView);
}
database.getDrawFactory().assignDefaultDatabaseIconTo(this, entryIconView, iconColor);
} else {
UUID uuid = Types.bytestoUUID(uuidBytes);
mEntry = pm.getEntryByUUIDId(uuid);
@@ -195,8 +193,12 @@ public class EntryEditActivity extends LockingHideActivity
fillData();
}
// Assign title
setTitle((mIsNew) ? getString(R.string.add_entry) : getString(R.string.edit_entry));
// 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);
}
@@ -259,9 +261,9 @@ public class EntryEditActivity extends LockingHideActivity
EntryEditActivity act = EntryEditActivity.this;
RunnableOnFinish task;
if ( mIsNew ) {
task = new AddEntryRunnable(act, App.getDB(), mCallbackNewEntry, onFinish);
task = new AddEntryRunnable(act, database, mCallbackNewEntry, onFinish);
} else {
task = new UpdateEntryRunnable(act, App.getDB(), mEntry, mCallbackNewEntry, onFinish);
task = new UpdateEntryRunnable(act, database, mEntry, mCallbackNewEntry, onFinish);
}
task.setUpdateProgressTaskStatus(
new UpdateProgressTaskStatus(this,
@@ -409,7 +411,7 @@ public class EntryEditActivity extends LockingHideActivity
newEntry.setLastModificationTime(new PwDate());
newEntry.setTitle(entryTitleView.getText().toString());
newEntry.setIcon(retrieveIcon());
newEntry.setIconStandard(retrieveIcon());
newEntry.setUrl(entryUrlView.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
* @return
*/
private PwIconStandard retrieveIcon() {
if(mSelectedIconID != UNDEFINED_ICON_ID)
return App.getDB().getPwDatabase().getIconFactory().getIcon(mSelectedIconID);
if (!mSelectedIconStandard.isUnknown())
return mSelectedIconStandard;
else {
if (mIsNew) {
return App.getDB().getPwDatabase().getIconFactory().getKeyIcon();
return database.getPwDatabase().getIconFactory().getKeyIcon();
}
else {
// Keep previous icon, if no new one was selected
@@ -475,13 +477,18 @@ public class EntryEditActivity extends LockingHideActivity
return super.onOptionsItemSelected(item);
}
private void assignIconView() {
database.getDrawFactory()
.assignDatabaseIconTo(
this,
entryIconView,
mEntry.getIcon(),
iconColor);
}
protected void fillData() {
if (IconPackChooser.getSelectedIconPack(this).tintable()) {
App.getDB().getDrawFactory().assignDatabaseIconTo(this, entryIconView, mEntry.getIcon(), true, iconColor);
} else {
App.getDB().getDrawFactory().assignDatabaseIconTo(this, entryIconView, mEntry.getIcon());
}
assignIconView();
// Don't start the field reference manager, we want to see the raw ref
mEntry.stopToManageFieldReferences();
@@ -515,14 +522,15 @@ public class EntryEditActivity extends LockingHideActivity
@Override
public void iconPicked(Bundle bundle) {
mSelectedIconID = bundle.getInt(IconPickerDialogFragment.KEY_ICON_ID);
entryIconView.setImageResource(IconPackChooser.getSelectedIconPack(this).iconToResId(mSelectedIconID));
mSelectedIconStandard = bundle.getParcelable(KEY_ICON_STANDARD);
mEntry.setIconStandard(mSelectedIconStandard);
assignIconView();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
if (mSelectedIconID != UNDEFINED_ICON_ID) {
outState.putInt(IconPickerDialogFragment.KEY_ICON_ID, mSelectedIconID);
if (!mSelectedIconStandard.isUnknown()) {
outState.putParcelable(KEY_ICON_STANDARD, mSelectedIconStandard);
super.onSaveInstanceState(outState);
}
}

View File

@@ -62,6 +62,7 @@ import com.kunzisoft.keepass.database.PwDatabase;
import com.kunzisoft.keepass.database.PwEntry;
import com.kunzisoft.keepass.database.PwGroup;
import com.kunzisoft.keepass.database.PwGroupId;
import com.kunzisoft.keepass.database.PwGroupV4;
import com.kunzisoft.keepass.database.PwIcon;
import com.kunzisoft.keepass.database.PwIconStandard;
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.ReadOnlyDialog;
import com.kunzisoft.keepass.dialogs.SortDialogFragment;
import com.kunzisoft.keepass.icons.IconPackChooser;
import com.kunzisoft.keepass.lock.LockingActivity;
import com.kunzisoft.keepass.password.AssignPasswordHelper;
import com.kunzisoft.keepass.selection.EntrySelectionHelper;
@@ -136,6 +136,8 @@ public class GroupActivity extends LockingActivity
private SearchEntryCursorAdapter searchSuggestionAdapter;
private int iconColor;
// After a database creation
public static void launch(Activity act) {
launch(act, READ_ONLY_DEFAULT);
@@ -267,6 +269,11 @@ public class GroupActivity extends LockingActivity
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;
if (currentGroupIsASearch)
fragmentTag = SEARCH_FRAGMENT_TAG;
@@ -439,15 +446,7 @@ public class GroupActivity extends LockingActivity
// Assign the group icon depending of IconPack or custom icon
iconView.setVisibility(View.VISIBLE);
if (mCurrentGroup != null) {
if (IconPackChooser.getSelectedIconPack(this).tintable()) {
// 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());
}
database.getDrawFactory().assignDatabaseIconTo(this, iconView, mCurrentGroup.getIcon(), iconColor);
if (toolbar != null) {
if (mCurrentGroup.containsParent())
@@ -706,6 +705,7 @@ public class GroupActivity extends LockingActivity
// Refresh the elements
assignGroupViewElements();
// Refresh suggestions to change preferences
if (searchSuggestionAdapter != null)
searchSuggestionAdapter.reInit(this);
}
@@ -978,7 +978,7 @@ public class GroupActivity extends LockingActivity
try {
iconStandard = (PwIconStandard) icon;
} catch (Exception ignored) {} // TODO custom icon
newGroup.setIcon(iconStandard);
newGroup.setIconStandard(iconStandard);
// If group created save it in the database
AddGroupRunnable addGroupRunnable = new AddGroupRunnable(this,
@@ -1000,8 +1000,11 @@ public class GroupActivity extends LockingActivity
updateGroup.setName(name);
try {
iconStandard = (PwIconStandard) icon;
} catch (Exception ignored) {} // TODO custom icon
updateGroup.setIcon(iconStandard);
updateGroup = ((PwGroupV4) oldGroupToUpdate).clone(); // TODO generalize
} catch (Exception e) {
e.printStackTrace();
} // TODO custom icon
updateGroup.setIconStandard(iconStandard);
if (listNodesFragment != null)
listNodesFragment.removeNode(oldGroupToUpdate);

View File

@@ -42,7 +42,6 @@ import com.kunzisoft.keepass.database.PwEntry;
import com.kunzisoft.keepass.database.PwGroup;
import com.kunzisoft.keepass.database.PwNode;
import com.kunzisoft.keepass.database.SortNodeEnum;
import com.kunzisoft.keepass.icons.IconPackChooser;
import com.kunzisoft.keepass.settings.PreferencesUtil;
import com.kunzisoft.keepass.utils.Util;
@@ -224,7 +223,6 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
public void onBindViewHolder(@NonNull BasicViewHolder holder, int position) {
PwNode subNode = nodeSortedList.get(position);
// Assign image
if (IconPackChooser.getSelectedIconPack(context).tintable()) {
int iconColor = Color.BLACK;
switch (subNode.getType()) {
case GROUP:
@@ -234,10 +232,7 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
iconColor = iconEntryColor;
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
holder.text.setText(subNode.getTitle());
// Assign click

View File

@@ -36,7 +36,6 @@ import com.kunzisoft.keepass.database.PwEntry;
import com.kunzisoft.keepass.database.PwIcon;
import com.kunzisoft.keepass.database.PwIconFactory;
import com.kunzisoft.keepass.database.cursor.EntryCursor;
import com.kunzisoft.keepass.icons.IconPackChooser;
import com.kunzisoft.keepass.settings.PreferencesUtil;
import java.util.UUID;
@@ -102,16 +101,15 @@ public class SearchEntryCursorAdapter extends CursorAdapter {
ViewHolder viewHolder = (ViewHolder) view.getTag();
// Assign image
if (IconPackChooser.getSelectedIconPack(context).tintable()) {
database.getDrawFactory().assignDatabaseIconTo(context, viewHolder.imageViewIcon, icon, true, iconColor);
} else {
database.getDrawFactory().assignDatabaseIconTo(context, viewHolder.imageViewIcon, icon);
}
database.getDrawFactory().assignDatabaseIconTo(context, viewHolder.imageViewIcon, icon, iconColor);
// Assign title
String showTitle = PwEntry.getVisualTitle(false, title, username, url, uuid);
viewHolder.textViewTitle.setText(showTitle);
if (displayUsername && !username.isEmpty()) {
viewHolder.textViewSubTitle.setText(String.format("(%s)", username));
} else {
viewHolder.textViewSubTitle.setText("");
}
}

View File

@@ -205,17 +205,21 @@ public class Database {
// TODO real content provider
if (!query.isEmpty()) {
PwGroup searchResult = search(query, 6);
PwVersion version = getPwDatabase().getVersion();
for (int i=0; i < searchResult.numbersOfChildEntries(); i++) {
PwEntry entry = searchResult.getChildEntryAt(i);
if (!entry.isMetaStream()) { // TODO metastream
try {
switch (getPwDatabase().getVersion()) {
switch (version) {
case V3:
cursor.addEntry((PwEntryV3) entry);
continue;
case V4:
cursor.addEntry((PwEntryV4) entry);
}
} catch (Exception e) {
Log.e(TAG, "This version of PwGroup can't be populated", e);
Log.e(TAG, "This version of PwEntry can't be added to the cursor", e);
}
}
}
}
@@ -223,20 +227,22 @@ public class Database {
}
public void populateEntry(PwEntry pwEntry, EntryCursor cursor) {
// TODO invert field reference manager
pwEntry.startToManageFieldReferences(getPwDatabase());
PwIconFactory iconFactory = getPwDatabase().getIconFactory();
try {
switch (getPwDatabase().getVersion()) {
case V3:
cursor.populateEntry((PwEntryV3) pwEntry, iconFactory);
break;
case V4:
// TODO invert field reference manager
pwEntry.startToManageFieldReferences(getPwDatabase());
cursor.populateEntry((PwEntryV4) pwEntry, iconFactory);
pwEntry.stopToManageFieldReferences();
break;
}
} catch (Exception e) {
Log.e(TAG, "This version of PwGroup can't be populated", e);
}
pwEntry.stopToManageFieldReferences();
}
public void saveData(Context ctx) throws IOException, PwDbOutputException {
@@ -515,18 +521,17 @@ public class Database {
}
public PwEntry createEntry(@Nullable PwGroup parent) {
PwEntry newPwEntry = null;
try {
switch (getPwDatabase().getVersion()) {
case V3:
newPwEntry = new PwEntryV3((PwGroupV3) parent);
return new PwEntryV3((PwGroupV3) parent);
case V4:
newPwEntry = new PwEntryV4((PwGroupV4) parent);
return new PwEntryV4((PwGroupV4) parent);
}
} catch (Exception e) {
Log.e(TAG, "This version of PwEntry can't be created", e);
}
return newPwEntry;
return null;
}
public PwGroup createGroup(PwGroup parent) {

View File

@@ -35,7 +35,7 @@ import java.util.List;
import java.util.Map;
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>> {
public static final UUID UUID_ZERO = new UUID(0,0);

View File

@@ -91,7 +91,7 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
PwGroupV3 group = createGroup();
group.setId(newGroupId());
group.setName(name);
group.setIcon(iconFactory.getIcon(iconId));
group.setIconStandard(iconFactory.getIcon(iconId));
addGroupTo(group, parent);
}
@@ -176,7 +176,7 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
*/
for (int i = 0; i < entries.size(); i++) {
PwEntryV3 ent = entries.get(i);
if (ent.getGroupId() == parent.getGroupId())
if (ent.getParent().getGroupId() == parent.getGroupId())
kids.add(ent);
}
return kids;

View File

@@ -77,8 +77,6 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
private static final String PMS_ID_USER = "SYSTEM";
private static final String PMS_ID_URL = "$";
// TODO Parent ID to remove
private int groupId;
private String title;
private String username;
private byte[] password;
@@ -94,12 +92,10 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
public PwEntryV3(PwGroupV3 p) {
construct(p);
groupId = ((PwGroupIdV3) this.parent.getId()).getId(); // TODO remove
}
public PwEntryV3(Parcel in) {
super(in);
groupId = in.readInt();
title = in.readString();
username = in.readString();
in.readByteArray(password);
@@ -112,7 +108,6 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(groupId);
dest.writeString(title);
dest.writeString(username);
dest.writeByteArray(password);
@@ -136,7 +131,6 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
protected void updateWith(PwEntryV3 source) {
super.assign(source);
groupId = source.groupId;
title = source.title;
username = source.username;
@@ -182,12 +176,9 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
return newEntry;
}
public int getGroupId() {
return groupId;
}
public void setGroupId(int groupId) {
this.groupId = groupId;
this.parent = new PwGroupV3();
this.parent.setGroupId(groupId);
}
@Override

View File

@@ -93,7 +93,8 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
parentGroupLastMod = in.readParcelable(PwDate.class.getClassLoader());
customData = MemUtil.readStringParcelableMap(in);
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();
backgroupColor = in.readString();
overrideURL = in.readString();
@@ -112,7 +113,7 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
dest.writeParcelable(parentGroupLastMod, flags);
MemUtil.writeStringParcelableMap(dest, customData);
dest.writeParcelable(fields, flags);
MemUtil.writeStringParcelableMap(dest, flags, binaries);
// TODO MemUtil.writeStringParcelableMap(dest, flags, binaries);
dest.writeString(foregroundColor);
dest.writeString(backgroupColor);
dest.writeString(overrideURL);
@@ -241,14 +242,6 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
fields.putProtectedString(key, value, protect);
}
public PwIconCustom getCustomIcon() {
return customIcon;
}
public void setCustomIcon(PwIconCustom icon) {
this.customIcon = icon;
}
public PwDate getLocationChanged() {
return parentGroupLastMod;
}
@@ -277,13 +270,26 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
@Override
public PwIcon getIcon() {
if (customIcon == null || customIcon.getUUID().equals(PwDatabase.UUID_ZERO)) {
if (customIcon == null || customIcon.isUnknown()) {
return super.getIcon();
} else {
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
public boolean allowExtraFields() {
return true;

View File

@@ -24,14 +24,14 @@ import android.os.Parcel;
import java.util.ArrayList;
import java.util.List;
public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup, ChildEntry extends PwEntry>
extends PwNode<Parent> {
public abstract class PwGroup<GroupG extends PwGroup, EntryE extends PwEntry>
extends PwNode<GroupG> {
protected String name = "";
// TODO verify children not needed
transient protected List<ChildGroup> childGroups = new ArrayList<>();
transient protected List<ChildEntry> childEntries = new ArrayList<>();
transient protected List<GroupG> childGroups = new ArrayList<>();
transient protected List<EntryE> childEntries = new ArrayList<>();
protected PwGroup() {
super();
@@ -54,48 +54,48 @@ public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup
return (PwGroup) super.clone();
}
protected void assign(PwGroup<Parent, ChildGroup, ChildEntry> source) {
protected void assign(PwGroup<GroupG, EntryE> source) {
super.assign(source);
name = source.name;
}
public List<ChildGroup> getChildGroups() {
public List<GroupG> getChildGroups() {
return childGroups;
}
public List<ChildEntry> getChildEntries() {
public List<EntryE> getChildEntries() {
return childEntries;
}
public void setGroups(List<ChildGroup> groups) {
public void setGroups(List<GroupG> groups) {
childGroups = groups;
}
public void setEntries(List<ChildEntry> entries) {
public void setEntries(List<EntryE> entries) {
childEntries = entries;
}
public void addChildGroup(ChildGroup group) {
public void addChildGroup(GroupG group) {
this.childGroups.add(group);
}
public void addChildEntry(ChildEntry entry) {
public void addChildEntry(EntryE entry) {
this.childEntries.add(entry);
}
public ChildGroup getChildGroupAt(int number) {
public GroupG getChildGroupAt(int number) {
return this.childGroups.get(number);
}
public ChildEntry getChildEntryAt(int number) {
public EntryE getChildEntryAt(int number) {
return this.childEntries.get(number);
}
public void removeChildGroup(ChildGroup group) {
public void removeChildGroup(GroupG group) {
this.childGroups.remove(group);
}
public void removeChildEntry(ChildEntry entry) {
public void removeChildEntry(EntryE entry) {
this.childEntries.remove(entry);
}
@@ -119,7 +119,7 @@ public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup
public List<PwNode> getDirectChildren() {
List<PwNode> children = new ArrayList<>();
children.addAll(childGroups);
for(ChildEntry child : childEntries) {
for(EntryE child : childEntries) {
if (!child.isMetaStream())
children.add(child);
}
@@ -154,15 +154,15 @@ public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup
return false;
}
public boolean preOrderTraverseTree(GroupHandler<ChildGroup> groupHandler,
EntryHandler<ChildEntry> entryHandler) {
public boolean preOrderTraverseTree(GroupHandler<GroupG> groupHandler,
EntryHandler<EntryE> entryHandler) {
if (entryHandler != null) {
for (ChildEntry entry : childEntries) {
for (EntryE entry : childEntries) {
if (!entryHandler.operate(entry)) return false;
}
}
for (ChildGroup group : childGroups) {
for (GroupG group : childGroups) {
if ((groupHandler != null) && !groupHandler.operate(group)) return false;
group.preOrderTraverseTree(groupHandler, entryHandler);
}

View File

@@ -22,7 +22,7 @@ package com.kunzisoft.keepass.database;
import android.os.Parcel;
public class PwGroupV3 extends PwGroup<PwGroupV3, PwGroupV3, PwEntryV3> {
public class PwGroupV3 extends PwGroup<PwGroupV3, PwEntryV3> {
// for tree traversing
private int groupId;

View File

@@ -27,7 +27,7 @@ import java.util.HashMap;
import java.util.Map;
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;
@@ -65,7 +65,7 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
customIcon = in.readParcelable(PwIconCustom.class.getClassLoader());
usageCount = in.readLong();
parentGroupLastMod = in.readParcelable(PwDate.class.getClassLoader());
customData = MemUtil.readStringParcelableMap(in);
// TODO customData = MemUtil.readStringParcelableMap(in);
expires = in.readByte() != 0;
notes = in.readString();
isExpanded = in.readByte() != 0;
@@ -84,7 +84,7 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
dest.writeParcelable(customIcon, flags);
dest.writeLong(usageCount);
dest.writeParcelable(parentGroupLastMod, flags);
MemUtil.writeStringParcelableMap(dest, customData);
// TODO MemUtil.writeStringParcelableMap(dest, customData);
dest.writeByte((byte) (expires ? 1 : 0));
dest.writeString(notes);
dest.writeByte((byte) (isExpanded ? 1 : 0));
@@ -169,14 +169,6 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
this.uuid = uuid;
}
public PwIconCustom getCustomIcon() {
return customIcon;
}
public void setCustomIcon(PwIconCustom icon) {
this.customIcon = icon;
}
@Override
public PwGroupId getId() {
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) {
customData.put(key, value);
}

View File

@@ -27,7 +27,7 @@ public class PwIconCustom extends PwIcon {
public static final PwIconCustom ZERO = new PwIconCustom(PwDatabase.UUID_ZERO, new byte[0]);
private final UUID uuid;
private byte[] imageData;
transient private byte[] imageData;
public PwIconCustom(UUID uuid, byte[] data) {
super();
@@ -44,7 +44,8 @@ public class PwIconCustom extends PwIcon {
protected PwIconCustom(Parcel in) {
super(in);
uuid = (UUID) in.readSerializable();
in.readByteArray(imageData);
// TODO Take too much memories
// in.readByteArray(imageData);
}
@Override
@@ -67,7 +68,7 @@ public class PwIconCustom extends PwIcon {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeSerializable(uuid);
dest.writeByteArray(imageData);
// Too big for a parcelable dest.writeByteArray(imageData);
}
public static final Creator<PwIconCustom> CREATOR = new Creator<PwIconCustom>() {

View File

@@ -37,6 +37,10 @@ public class PwIconFactory {
*/
private ReferenceMap customCache = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK);
public PwIconStandard getUnknownIcon() {
return getIcon(PwIconStandard.UNKNOWN);
}
public PwIconStandard getKeyIcon() {
return getIcon(PwIconStandard.KEY);
}

View File

@@ -132,14 +132,14 @@ public abstract class PwNode<Parent extends PwGroup> implements ISmallTimeLogger
* @return Visual icon
*/
public PwIcon getIcon() {
return icon;
return getIconStandard();
}
public PwIconStandard getIconStandard() {
return icon;
}
public void setIcon(PwIconStandard icon) {
public void setIconStandard(PwIconStandard icon) {
this.icon = icon;
}

View File

@@ -31,15 +31,15 @@ import java.util.List;
public class DeleteGroupRunnable extends ActionNodeDatabaseRunnable {
private PwGroup<PwGroup, PwGroup, PwEntry> mGroupToDelete;
private PwGroup<PwGroup, PwEntry> mGroupToDelete;
private PwGroup mParent;
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);
}
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);
mGroupToDelete = group;
}

View File

@@ -67,8 +67,8 @@ public class EntryCursor extends MatrixCursor {
entry.getUUID().getLeastSignificantBits(),
entry.getTitle(),
entry.getIconStandard().getIconId(),
entry.getCustomIcon().getUUID().getMostSignificantBits(),
entry.getCustomIcon().getUUID().getLeastSignificantBits(),
entry.getIconCustom().getUUID().getMostSignificantBits(),
entry.getIconCustom().getUUID().getLeastSignificantBits(),
entry.getUsername(),
entry.getPassword(),
entry.getUrl(),
@@ -88,7 +88,7 @@ public class EntryCursor extends MatrixCursor {
pwEntry.setTitle(getString(getColumnIndex(EntryCursor.COLUMN_INDEX_TITLE)));
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.setPassword(getString(getColumnIndex(EntryCursor.COLUMN_INDEX_PASSWORD)));
@@ -107,7 +107,7 @@ public class EntryCursor extends MatrixCursor {
PwIconCustom iconCustom = iconFactory.getIcon(
new UUID(getLong(getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_MOST_SIGNIFICANT_BITS)),
getLong(getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_LEAST_SIGNIFICANT_BITS))));
pwEntry.setCustomIcon(iconCustom);
pwEntry.setIconCustom(iconCustom);
// Retrieve extra fields
if (extraFieldCursor.moveToFirst()) {

View File

@@ -316,7 +316,7 @@ public class ImporterV3 extends Importer {
grp.setExpiryTime(new PwDate(buf, offset));
break;
case 0x0007 :
grp.setIcon(db.getIconFactory().getIcon(LEDataInputStream.readInt(buf, offset)));
grp.setIconStandard(db.getIconFactory().getIcon(LEDataInputStream.readInt(buf, offset)));
break;
case 0x0008 :
grp.setLevel(LEDataInputStream.readUShort(buf, offset));
@@ -353,7 +353,7 @@ public class ImporterV3 extends Importer {
iconId = 0;
}
ent.setIcon(db.getIconFactory().getIcon(iconId));
ent.setIconStandard(db.getIconFactory().getIcon(iconId));
break;
case 0x0004 :
ent.setTitle(Types.readCString(buf, offset));

View File

@@ -556,9 +556,9 @@ public class ImporterV4 extends Importer {
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemNotes) ) {
ctxGroup.setNotes(ReadString(xpp));
} 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) ) {
ctxGroup.setCustomIcon(db.getIconFactory().getIcon(ReadUuid(xpp)));
ctxGroup.setIconCustom(db.getIconFactory().getIcon(ReadUuid(xpp)));
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemTimes) ) {
return SwitchContext(ctx, KdbContext.GroupTimes, xpp);
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemIsExpanded) ) {
@@ -611,9 +611,9 @@ public class ImporterV4 extends Importer {
if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemUuid) ) {
ctxEntry.setUUID(ReadUuid(xpp));
} 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) ) {
ctxEntry.setCustomIcon(db.getIconFactory().getIcon(ReadUuid(xpp)));
ctxEntry.setIconCustom(db.getIconFactory().getIcon(ReadUuid(xpp)));
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemFgColor) ) {
ctxEntry.setForegroundColor(ReadString(xpp));
} else if ( name.equalsIgnoreCase(PwDatabaseV4XML.ElemBgColor) ) {

View File

@@ -352,8 +352,8 @@ public class PwDbV4Output extends PwDbOutput<PwDbHeaderV4> {
writeObject(PwDatabaseV4XML.ElemNotes, group.getNotes());
writeObject(PwDatabaseV4XML.ElemIcon, group.getIconStandard().getIconId());
if (!group.getCustomIcon().equals(PwIconCustom.ZERO)) {
writeObject(PwDatabaseV4XML.ElemCustomIconID, group.getCustomIcon().getUUID());
if (!group.getIconCustom().equals(PwIconCustom.ZERO)) {
writeObject(PwDatabaseV4XML.ElemCustomIconID, group.getIconCustom().getUUID());
}
writeList(PwDatabaseV4XML.ElemTimes, group);
@@ -377,8 +377,8 @@ public class PwDbV4Output extends PwDbOutput<PwDbHeaderV4> {
writeObject(PwDatabaseV4XML.ElemUuid, entry.getUUID());
writeObject(PwDatabaseV4XML.ElemIcon, entry.getIconStandard().getIconId());
if (!entry.getCustomIcon().equals(PwIconCustom.ZERO)) {
writeObject(PwDatabaseV4XML.ElemCustomIconID, entry.getCustomIcon().getUUID());
if (!entry.getIconCustom().equals(PwIconCustom.ZERO)) {
writeObject(PwDatabaseV4XML.ElemCustomIconID, entry.getIconCustom().getUUID());
}
writeObject(PwDatabaseV4XML.ElemFgColor, entry.getForegroundColor());

View File

@@ -79,7 +79,7 @@ public class PwEntryOutputV3 {
// Group ID
mOS.write(GROUPID_FIELD_TYPE);
mOS.write(LONG_FOUR);
mOS.write(LEDataOutputStream.writeIntBuf(mPE.getGroupId()));
mOS.write(LEDataOutputStream.writeIntBuf(mPE.getParent().getGroupId()));
// Image ID
mOS.write(IMAGEID_FIELD_TYPE);

View File

@@ -42,7 +42,7 @@ import java.util.Locale;
import java.util.Queue;
public class SearchDbHelper<PwDatabaseVersion extends PwDatabase<PwGroupSearch, PwEntrySearch>,
PwGroupSearch extends PwGroup<PwGroupSearch, PwGroupSearch, PwEntrySearch>,
PwGroupSearch extends PwGroup<PwGroupSearch, PwEntrySearch>,
PwEntrySearch extends PwEntry<PwGroupSearch>> {
private final Context mCtx;

View File

@@ -35,9 +35,9 @@ import android.widget.Toast;
import com.kunzisoft.keepass.R;
import com.kunzisoft.keepass.app.App;
import com.kunzisoft.keepass.database.Database;
import com.kunzisoft.keepass.database.PwGroup;
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.UPDATE;
@@ -49,9 +49,11 @@ public class GroupEditDialogFragment extends DialogFragment
public static final String TAG_CREATE_GROUP = "TAG_CREATE_GROUP";
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";
private Database database;
private EditGroupListener editGroupListener;
private EditGroupDialogAction editGroupDialogAction;
@@ -59,6 +61,7 @@ public class GroupEditDialogFragment extends DialogFragment
private PwIcon iconGroup;
private ImageView iconButton;
private int iconColor;
public enum EditGroupDialogAction {
CREATION, UPDATE, NONE;
@@ -79,7 +82,7 @@ public class GroupEditDialogFragment extends DialogFragment
public static GroupEditDialogFragment build(PwGroup group) {
Bundle bundle = new Bundle();
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());
GroupEditDialogFragment fragment = new GroupEditDialogFragment();
fragment.setArguments(bundle);
@@ -112,20 +115,21 @@ public class GroupEditDialogFragment extends DialogFragment
// Retrieve the textColor to tint the icon
int[] attrs = {android.R.attr.textColorPrimary};
TypedArray ta = getActivity().getTheme().obtainStyledAttributes(attrs);
int iconColor = ta.getColor(0, Color.WHITE);
iconColor = ta.getColor(0, Color.WHITE);
// Init elements
database = App.getDB();
editGroupDialogAction = EditGroupDialogAction.NONE;
nameGroup = "";
iconGroup = App.getDB().getPwDatabase().getIconFactory().getFolderIcon();
iconGroup = database.getPwDatabase().getIconFactory().getFolderIcon();
if (savedInstanceState != null
&& savedInstanceState.containsKey(KEY_ACTION_ID)
&& savedInstanceState.containsKey(KEY_NAME)
&& savedInstanceState.containsKey(KEY_ICON_ID)) {
&& savedInstanceState.containsKey(KEY_ICON)) {
editGroupDialogAction = getActionFromOrdinal(savedInstanceState.getInt(KEY_ACTION_ID));
nameGroup = savedInstanceState.getString(KEY_NAME);
iconGroup = savedInstanceState.getParcelable(KEY_ICON_ID);
iconGroup = savedInstanceState.getParcelable(KEY_ICON);
} else {
@@ -135,30 +139,16 @@ public class GroupEditDialogFragment extends DialogFragment
if (getArguments() != null
&& getArguments().containsKey(KEY_NAME)
&& getArguments().containsKey(KEY_ICON_ID)) {
&& getArguments().containsKey(KEY_ICON)) {
nameGroup = getArguments().getString(KEY_NAME);
iconGroup = getArguments().getParcelable(KEY_ICON_ID);
iconGroup = getArguments().getParcelable(KEY_ICON);
}
}
// populate the name
nameField.setText(nameGroup);
// populate the icon
if (IconPackChooser.getSelectedIconPack(getContext()).tintable()) {
App.getDB().getDrawFactory()
.assignDatabaseIconTo(
getContext(),
iconButton,
iconGroup,
true,
iconColor);
} else {
App.getDB().getDrawFactory()
.assignDatabaseIconTo(
getContext(),
iconButton,
iconGroup);
}
assignIconView();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(root)
@@ -195,18 +185,26 @@ public class GroupEditDialogFragment extends DialogFragment
return builder.create();
}
private void assignIconView() {
database.getDrawFactory()
.assignDatabaseIconTo(
getContext(),
iconButton,
iconGroup,
iconColor);
}
@Override
public void iconPicked(Bundle bundle) {
int selectedIconID = bundle.getInt(IconPickerDialogFragment.KEY_ICON_ID);
iconButton.setImageResource(IconPackChooser.getSelectedIconPack(getContext()).iconToResId(selectedIconID));
iconGroup = App.getDB().getPwDatabase().getIconFactory().getIcon(selectedIconID);
iconGroup = bundle.getParcelable(IconPickerDialogFragment.KEY_ICON_STANDARD);
assignIconView();
}
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putInt(KEY_ACTION_ID, editGroupDialogAction.ordinal());
outState.putString(KEY_NAME, nameGroup);
outState.putParcelable(KEY_ICON_ID, iconGroup);
outState.putParcelable(KEY_ICON, iconGroup);
super.onSaveInstanceState(outState);
}

View File

@@ -37,14 +37,16 @@ import android.widget.GridView;
import android.widget.ImageView;
import com.kunzisoft.keepass.R;
import com.kunzisoft.keepass.database.PwIconStandard;
import com.kunzisoft.keepass.icons.IconPack;
import com.kunzisoft.keepass.icons.IconPackChooser;
import com.kunzisoft.keepass.stylish.StylishActivity;
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 IconPack iconPack;
@@ -85,7 +87,7 @@ public class IconPickerDialogFragment extends DialogFragment {
currIconGridView.setOnItemClickListener((parent, v, position, id) -> {
Bundle bundle = new Bundle();
bundle.putInt(KEY_ICON_ID, position);
bundle.putParcelable(KEY_ICON_STANDARD, new PwIconStandard(position));
iconPickerListener.iconPicked(bundle);
dismiss();
});

View File

@@ -65,50 +65,48 @@ public class IconDrawableFactory {
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 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) {
assignDefaultDatabaseIconTo(context, iv, false, Color.WHITE);
}
/**
* Assign a default database icon to an ImageView and tint it
*
* @param context Context to build the drawable
* @param iv 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
*/
public void assignDatabaseIconTo(Context context, ImageView iv, PwIcon icon) {
assignDatabaseIconTo(context, iv, icon, 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,
public void assignDefaultDatabaseIconTo(Context context, ImageView iconView, int tintColor) {
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 database icon to an ImageView and tint it if needed
*
* @param context Context to build the drawable
* @param iconView ImageView that will host the drawable
* @param icon The icon from the database
* @param tintColor Use this color to tint tintable icon
*/
public void assignDatabaseIconTo(Context context, ImageView iconView, PwIcon icon, int tintColor) {
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);
}
}
/**

View File

@@ -23,6 +23,7 @@
<string name="about_description">KeePass DX is an Android implementation of the KeePass password manager.</string>
<string name="accept">Accept</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_string">Add string</string>
<string name="encryption">Encryption</string>

View File

@@ -1,5 +1,6 @@
* New search in a single fragment
* Search suggestions
* Fix read-only mode
* Added the display of usernames
* Added translations
* Fix parcelable / toolbar
* Fix read-only mode
* Fix parcelable / toolbar / back

View File

@@ -1,5 +1,6 @@
* Nouvelle recherche dans un seul fragment
* Suggestions de recherche
* Correction du mode lecture seule
* Ajout de l'affichage des noms d'utilisateurs
* Ajout de traductions
* Correction de parcelable / de barre de navigation
* Correction du mode lecture seule
* Correction de parcelable / barre de navigation / retour