Username can be displayed in lists

This commit is contained in:
PhilippC 2013-05-14 06:20:43 +02:00
parent 13d7062519
commit e93e9307de
7 changed files with 866 additions and 813 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file is based on Keepassdroid, Copyright Brian Pellin.
Keepass2Android 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.
Keepass2Android 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 Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
-->
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<ImageView android:id="@+id/entry_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:scaleType="fitXY"
android:src="@drawable/ic99_blank"/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/entry_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
style="@style/ElementTextLarge"/>
<View/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<ImageView
android:id="@+id/entry_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:scaleType="fitXY"
android:src="@drawable/ic99_blank" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/entry_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="abc"
style="@style/ElementTextLarge" />
<TextView
android:id="@+id/entry_text_detail"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="abcde"
style="@style/ElementTextSmall" />
</LinearLayout>
<View />
</TableRow>
</TableLayout>

View File

@ -41,6 +41,7 @@
<string name="sort_key">sort_key</string>
<string name="timeout_key">timeout_key</string>
<string name="TanExpiresOnUse_key">TanExpiresOnUse_key</string>
<string name="ShowUsernameInList_key">ShowUsernameInList_key</string>
<string name="default_username_key">defaultUsername</string>
<string name="database_name_key">databaseName</string>
<string name="BinaryDirectory_key">binaryDirectory</string>
@ -50,6 +51,7 @@
<bool name="sort_default">true</bool>
<bool name="omitbackup_default">true</bool>
<bool name="TanExpiresOnUse_default">true</bool>
<bool name="ShowUsernameInList_default">true</bool>
<string name="QuickUnlockDefaultEnabled_key">Enable_QuickUnlock_by_default</string>
<string name="QuickUnlockLength_key">QuickUnlockLength</string>

View File

@ -173,6 +173,8 @@
<string name="regular_expression">Regular expression</string>
<string name="TanExpiresOnUse_title">Tan expires on use</string>
<string name="TanExpiresOnUse_summary">Mark TAN entries expired when using them</string>
<string name="ShowUsernameInList_title">Display username in list</string>
<string name="ShowUsernameInList_summary">Display usernames below entry titles. Useful for multiple accounts or TANs.</string>
<string name="kp2a_findUrl">Keepass2Android: Find password</string>
<string name="excludeExpiredEntries">Exclude expired entries</string>
<string name="search_options">Options</string>
@ -235,7 +237,7 @@
<string name="translate_app">Translate KP2A</string>
<string name="ChangeLog_title">Change log</string>
<string name="ChangeLog_0_8_2"><b>Version 0.8.2</b>\n
* Support for Digest Authentication in WebDAV
* Support for Digest Authentication in WebDAV\n
* Bugfixes (OI File manager, Open URL)
</string>
<string name="ChangeLog_0_8_1"><b>Version 0.8.1</b>\n

View File

@ -82,6 +82,12 @@
android:summary="@string/TanExpiresOnUse_summary"
android:defaultValue="@bool/TanExpiresOnUse_default"/>
<CheckBoxPreference
android:key="@string/ShowUsernameInList_key"
android:title="@string/ShowUsernameInList_title"
android:summary="@string/ShowUsernameInList_summary"
android:defaultValue="@bool/ShowUsernameInList_default"/>
<ListPreference
android:key="@string/list_size_key"
android:title="@string/list_size_title"

View File

@ -38,6 +38,10 @@ namespace keepass2android
return float.Parse(prefs.GetString(ctx.GetString(Resource.String.list_size_key), ctx.GetString(Resource.String.list_size_default)));
}
public static float getListDetailTextSize(Context ctx) {
return (float)Math.Round(getListTextSize(ctx)*3.0f/4.0f);
}
}
}

View File

@ -28,6 +28,7 @@ using Android.Widget;
using KeePassLib;
using Android.Text;
using Android.Text.Style;
using Android.Preferences;
namespace keepass2android.view
{
@ -37,7 +38,11 @@ namespace keepass2android.view
protected GroupBaseActivity mAct;
protected PwEntry mPw;
private TextView mTv;
private TextView mTvDetails;
private int mPos;
bool mShowDetail;
protected const int MENU_OPEN = Menu.First;
private const int MENU_DELETE = MENU_OPEN + 1;
@ -60,7 +65,12 @@ namespace keepass2android.view
View ev = View.Inflate(mAct, Resource.Layout.entry_list_entry, null);
mTv = (TextView)ev.FindViewById(Resource.Id.entry_text);
mTv.TextSize = PrefsUtil.getListTextSize(act);
mTvDetails = (TextView)ev.FindViewById(Resource.Id.entry_text_detail);
mTvDetails.TextSize = PrefsUtil.getListDetailTextSize(act);
mShowDetail = PreferenceManager.GetDefaultSharedPreferences(act).GetBoolean(act.GetString(Resource.String.ShowUsernameInList_key), Resources.GetBoolean(Resource.Boolean.ShowUsernameInList_default));
populateView(ev, pw, pos);
LayoutParams lp = new LayoutParams(LayoutParams.FillParent, LayoutParams.WrapContent);
@ -93,7 +103,25 @@ namespace keepass2android.view
}
mTv.TextFormatted = str;
String detail = pw.Strings.ReadSafe(PwDefs.UserNameField);
if ((mShowDetail == false) || (String.IsNullOrEmpty(detail)))
{
mTvDetails.Visibility = ViewStates.Gone;
}
else
{
var strDetail = new SpannableString(detail);
if (isExpired)
{
strDetail.SetSpan(new StrikethroughSpan(), 0, detail.Length, SpanTypes.ExclusiveExclusive);
}
mTvDetails.TextFormatted = strDetail;
mTvDetails.Visibility = ViewStates.Visible;
}
}
public void convertView(PwEntry pw, int pos)