mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Add new icon lookup logic, add contributors file
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.android.keepass"
|
package="com.android.keepass"
|
||||||
android:installLocation="auto" android:versionCode="54" android:versionName="1.6.3">
|
android:installLocation="auto" android:versionName="1.7" android:versionCode="55">
|
||||||
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8"/>
|
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8"/>
|
||||||
<supports-screens
|
<supports-screens
|
||||||
android:smallScreens="true"
|
android:smallScreens="true"
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
KeePassDroid (1.7)
|
||||||
|
* Add icon support from Tobias Selig
|
||||||
|
|
||||||
KeePassDroid (1.6.3)
|
KeePassDroid (1.6.3)
|
||||||
* Search tweaks from Johan Berts
|
* Search tweaks from Johan Berts
|
||||||
|
|
||||||
|
|||||||
5
CONTRIBUTORS
Normal file
5
CONTRIBUTORS
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Original author:
|
||||||
|
Brian Pellin
|
||||||
|
|
||||||
|
Johan Berts - search patches
|
||||||
|
Tobias Selig - icon support
|
||||||
@@ -55,6 +55,7 @@ import com.keepassdroid.database.PwEntry;
|
|||||||
import com.keepassdroid.database.PwEntryV3;
|
import com.keepassdroid.database.PwEntryV3;
|
||||||
import com.keepassdroid.database.PwEntryV4;
|
import com.keepassdroid.database.PwEntryV4;
|
||||||
import com.keepassdroid.intents.Intents;
|
import com.keepassdroid.intents.Intents;
|
||||||
|
import com.keepassdroid.utils.Icons;
|
||||||
import com.keepassdroid.utils.Types;
|
import com.keepassdroid.utils.Types;
|
||||||
import com.keepassdroid.utils.Util;
|
import com.keepassdroid.utils.Util;
|
||||||
|
|
||||||
@@ -212,12 +213,8 @@ public class EntryActivity extends LockCloseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fillData() {
|
private void fillData() {
|
||||||
int currIconResId = R.drawable.ic00 + mEntry.imageId;
|
ImageView iv = (ImageView) findViewById(R.id.entry_icon);
|
||||||
if (currIconResId < R.drawable.ic99_blank)
|
iv.setImageResource(Icons.iconToResId(mEntry.imageId));
|
||||||
{
|
|
||||||
ImageView iv = (ImageView) findViewById(R.id.entry_icon);
|
|
||||||
iv.setImageResource(currIconResId);
|
|
||||||
}
|
|
||||||
|
|
||||||
populateText(R.id.entry_title, mEntry.getTitle());
|
populateText(R.id.entry_title, mEntry.getTitle());
|
||||||
populateText(R.id.entry_user_name, mEntry.getUsername());
|
populateText(R.id.entry_user_name, mEntry.getUsername());
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import com.keepassdroid.database.edit.AddEntry;
|
|||||||
import com.keepassdroid.database.edit.OnFinish;
|
import com.keepassdroid.database.edit.OnFinish;
|
||||||
import com.keepassdroid.database.edit.RunnableOnFinish;
|
import com.keepassdroid.database.edit.RunnableOnFinish;
|
||||||
import com.keepassdroid.database.edit.UpdateEntry;
|
import com.keepassdroid.database.edit.UpdateEntry;
|
||||||
|
import com.keepassdroid.utils.Icons;
|
||||||
import com.keepassdroid.utils.Types;
|
import com.keepassdroid.utils.Types;
|
||||||
import com.keepassdroid.utils.Util;
|
import com.keepassdroid.utils.Util;
|
||||||
|
|
||||||
@@ -228,7 +229,7 @@ public class EntryEditActivity extends LockCloseActivity {
|
|||||||
case Activity.RESULT_OK:
|
case Activity.RESULT_OK:
|
||||||
mSelectedIconID = data.getExtras().getInt(IconPickerActivity.KEY_ICON_ID);
|
mSelectedIconID = data.getExtras().getInt(IconPickerActivity.KEY_ICON_ID);
|
||||||
ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button);
|
ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button);
|
||||||
currIconButton.setImageResource(R.drawable.ic00 + mSelectedIconID);
|
currIconButton.setImageResource(Icons.iconToResId(mSelectedIconID));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Activity.RESULT_CANCELED:
|
case Activity.RESULT_CANCELED:
|
||||||
@@ -292,13 +293,8 @@ public class EntryEditActivity extends LockCloseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fillData() {
|
private void fillData() {
|
||||||
int currIconResId = R.drawable.ic00 + mEntry.imageId;
|
ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button);
|
||||||
mSelectedIconID = mEntry.imageId;
|
currIconButton.setImageResource(Icons.iconToResId(mEntry.imageId));
|
||||||
if (currIconResId < R.drawable.ic99_blank)
|
|
||||||
{
|
|
||||||
ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button);
|
|
||||||
currIconButton.setImageResource(currIconResId);
|
|
||||||
}
|
|
||||||
|
|
||||||
populateText(R.id.entry_title, mEntry.title);
|
populateText(R.id.entry_title, mEntry.title);
|
||||||
populateText(R.id.entry_user_name, mEntry.getUsername());
|
populateText(R.id.entry_user_name, mEntry.getUsername());
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import android.widget.Toast;
|
|||||||
import com.android.keepass.R;
|
import com.android.keepass.R;
|
||||||
import com.keepassdroid.database.PwGroup;
|
import com.keepassdroid.database.PwGroup;
|
||||||
import com.keepassdroid.database.PwGroupV3;
|
import com.keepassdroid.database.PwGroupV3;
|
||||||
|
import com.keepassdroid.utils.Icons;
|
||||||
|
|
||||||
public class GroupEditActivity extends Activity
|
public class GroupEditActivity extends Activity
|
||||||
{
|
{
|
||||||
@@ -116,7 +117,7 @@ public class GroupEditActivity extends Activity
|
|||||||
case Activity.RESULT_OK:
|
case Activity.RESULT_OK:
|
||||||
mSelectedIconID = data.getExtras().getInt(IconPickerActivity.KEY_ICON_ID);
|
mSelectedIconID = data.getExtras().getInt(IconPickerActivity.KEY_ICON_ID);
|
||||||
ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button);
|
ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button);
|
||||||
currIconButton.setImageResource(R.drawable.ic00 + mSelectedIconID);
|
currIconButton.setImageResource(Icons.iconToResId(mSelectedIconID));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Activity.RESULT_CANCELED:
|
case Activity.RESULT_CANCELED:
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.keepass.R;
|
import com.android.keepass.R;
|
||||||
|
import com.keepassdroid.utils.Icons;
|
||||||
|
|
||||||
public class IconPickerActivity extends Activity
|
public class IconPickerActivity extends Activity
|
||||||
{
|
{
|
||||||
@@ -80,7 +81,7 @@ public class IconPickerActivity extends Activity
|
|||||||
public int getCount()
|
public int getCount()
|
||||||
{
|
{
|
||||||
/* Return number of KeePass icons */
|
/* Return number of KeePass icons */
|
||||||
return (R.drawable.ic99_blank - R.drawable.ic00);
|
return Icons.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getItem(int position)
|
public Object getItem(int position)
|
||||||
@@ -109,7 +110,7 @@ public class IconPickerActivity extends Activity
|
|||||||
TextView tv = (TextView) currView.findViewById(R.id.icon_text);
|
TextView tv = (TextView) currView.findViewById(R.id.icon_text);
|
||||||
tv.setText("" + position);
|
tv.setText("" + position);
|
||||||
ImageView iv = (ImageView) currView.findViewById(R.id.icon_image);
|
ImageView iv = (ImageView) currView.findViewById(R.id.icon_image);
|
||||||
iv.setImageResource(R.drawable.ic00 + position);
|
iv.setImageResource(Icons.iconToResId(position));
|
||||||
|
|
||||||
return currView;
|
return currView;
|
||||||
}
|
}
|
||||||
|
|||||||
80
src/com/keepassdroid/utils/Icons.java
Normal file
80
src/com/keepassdroid/utils/Icons.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 Brian Pellin.
|
||||||
|
*
|
||||||
|
* This file is part of KeePassDroid.
|
||||||
|
*
|
||||||
|
* KeePassDroid is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* KeePassDroid is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with KeePassDroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.keepassdroid.utils;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.android.keepass.R;
|
||||||
|
|
||||||
|
|
||||||
|
public class Icons {
|
||||||
|
private static Map<Integer, Integer> icons = null;
|
||||||
|
|
||||||
|
private static void buildList() {
|
||||||
|
if (icons == null) {
|
||||||
|
icons = new HashMap<Integer, Integer>();
|
||||||
|
|
||||||
|
Class<com.android.keepass.R.drawable> c = com.android.keepass.R.drawable.class;
|
||||||
|
|
||||||
|
Field[] fields = c.getFields();
|
||||||
|
|
||||||
|
for (int i = 0; i < fields.length; i++) {
|
||||||
|
String fieldName = fields[i].getName();
|
||||||
|
if (fieldName.matches("ic\\d{2}.*")) {
|
||||||
|
String sNum = fieldName.substring(2, 4);
|
||||||
|
int num = Integer.parseInt(sNum);
|
||||||
|
if (num > 69) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int resId;
|
||||||
|
try {
|
||||||
|
resId = fields[i].getInt(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
icons.put(num, resId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int iconToResId(int iconId) {
|
||||||
|
buildList();
|
||||||
|
|
||||||
|
Integer resId = icons.get(iconId);
|
||||||
|
|
||||||
|
if (resId == null) {
|
||||||
|
return R.drawable.ic99_blank;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int count() {
|
||||||
|
buildList();
|
||||||
|
|
||||||
|
return icons.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -34,6 +34,7 @@ import com.keepassdroid.GroupBaseActivity;
|
|||||||
import com.keepassdroid.database.PwEntry;
|
import com.keepassdroid.database.PwEntry;
|
||||||
import com.keepassdroid.database.PwEntryV3;
|
import com.keepassdroid.database.PwEntryV3;
|
||||||
import com.keepassdroid.settings.PrefsUtil;
|
import com.keepassdroid.settings.PrefsUtil;
|
||||||
|
import com.keepassdroid.utils.Icons;
|
||||||
|
|
||||||
public class PwEntryView extends ClickView {
|
public class PwEntryView extends ClickView {
|
||||||
|
|
||||||
@@ -59,12 +60,10 @@ public class PwEntryView extends ClickView {
|
|||||||
mPos = pos;
|
mPos = pos;
|
||||||
|
|
||||||
View ev = View.inflate(mAct, R.layout.entry_list_entry, null);
|
View ev = View.inflate(mAct, R.layout.entry_list_entry, null);
|
||||||
int currIconResId = R.drawable.ic00 + pw.imageId;
|
|
||||||
if (currIconResId < R.drawable.ic99_blank)
|
ImageView iv = (ImageView) ev.findViewById(R.id.entry_icon);
|
||||||
{
|
iv.setImageResource(Icons.iconToResId(pw.imageId));
|
||||||
ImageView iv = (ImageView) ev.findViewById(R.id.entry_icon);
|
|
||||||
iv.setImageResource(currIconResId);
|
|
||||||
}
|
|
||||||
TextView tv = (TextView) ev.findViewById(R.id.entry_text);
|
TextView tv = (TextView) ev.findViewById(R.id.entry_text);
|
||||||
tv.setText(mPw.getDisplayTitle());
|
tv.setText(mPw.getDisplayTitle());
|
||||||
tv.setTextSize(PrefsUtil.getListTextSize(act));
|
tv.setTextSize(PrefsUtil.getListTextSize(act));
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import com.keepassdroid.GroupBaseActivity;
|
|||||||
import com.keepassdroid.database.PwGroup;
|
import com.keepassdroid.database.PwGroup;
|
||||||
import com.keepassdroid.database.PwGroupV3;
|
import com.keepassdroid.database.PwGroupV3;
|
||||||
import com.keepassdroid.settings.PrefsUtil;
|
import com.keepassdroid.settings.PrefsUtil;
|
||||||
|
import com.keepassdroid.utils.Icons;
|
||||||
|
|
||||||
|
|
||||||
public class PwGroupView extends ClickView {
|
public class PwGroupView extends ClickView {
|
||||||
@@ -57,12 +58,10 @@ public class PwGroupView extends ClickView {
|
|||||||
mPw = pw;
|
mPw = pw;
|
||||||
|
|
||||||
View gv = View.inflate(act, R.layout.group_list_entry, null);
|
View gv = View.inflate(act, R.layout.group_list_entry, null);
|
||||||
int currIconResId = R.drawable.ic00 + pw.getIconId();
|
|
||||||
if (currIconResId < R.drawable.ic99_blank)
|
ImageView iv = (ImageView) gv.findViewById(R.id.group_icon);
|
||||||
{
|
iv.setImageResource(Icons.iconToResId(pw.getIconId()));
|
||||||
ImageView iv = (ImageView) gv.findViewById(R.id.group_icon);
|
|
||||||
iv.setImageResource(currIconResId);
|
|
||||||
}
|
|
||||||
TextView tv = (TextView) gv.findViewById(R.id.group_text);
|
TextView tv = (TextView) gv.findViewById(R.id.group_text);
|
||||||
tv.setText(pw.getName());
|
tv.setText(pw.getName());
|
||||||
float size = PrefsUtil.getListTextSize(act);
|
float size = PrefsUtil.getListTextSize(act);
|
||||||
|
|||||||
Reference in New Issue
Block a user