Add group details in search results

This commit is contained in:
Jareth Lomson 2014-05-25 14:04:36 +02:00
parent 7806d8bf4d
commit 0c982e455e
7 changed files with 1660 additions and 1588 deletions

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,12 @@
android:layout_width="wrap_content"
android:text="abcde"
style="@style/ElementTextSmall" />
<TextView
android:id="@+id/group_detail"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:text="group detail"
style="@style/GroupDetailInSearchResult" />
</LinearLayout>
<View />
</TableRow>

View File

@ -58,6 +58,7 @@
<string name="design_key">design_key</string>
<string name="sort_key">sort_key</string>
<string name="TanExpiresOnUse_key">TanExpiresOnUse_key</string>
<string name="ShowGroupnameInSearchResult_key">ShowGroupnameInSearchResult_key</string>
<string name="ShowUsernameInList_key">ShowUsernameInList_key</string>
<string name="RememberRecentFiles_key">RememberRecentFiles_key</string>
<string name="default_username_key">defaultUsername</string>
@ -70,6 +71,7 @@
<bool name="omitbackup_default">true</bool>
<bool name="TanExpiresOnUse_default">true</bool>
<bool name="ShowUsernameInList_default">true</bool>
<bool name="ShowGroupnameInSearchResult_default">true</bool>
<bool name="RememberRecentFiles_default">true</bool>

View File

@ -26,6 +26,8 @@
<string name="show_kill_app_summary">Show a button in password screen to kill the application process (for paranoid users)</string>
<string name="application">Application</string>
<string name="application_settings">Application settings</string>
<string name="ShowGroupnameInSearchResult_title">Display groupname in search result</string>
<string name="ShowGroupnameInSearchResult_resume">Display groupname below entry titles. Usefull if several entries have the same name.</string>
<string name="security_prefs">Security</string>
<string name="display_prefs">Display</string>

View File

@ -56,6 +56,9 @@
<item name="@android:textColor">#ffffff</item>
<item name="@android:textSize">20sp</item>
</style>
<style name="GroupDetailInSearchResult" parent="ElementTextSmall">
<item name="@android:textStyle">italic</item>
</style>
<style name="WhiteOnBlackSmall" parent="WhiteOnBlack">
<item name="@android:textSize">12sp</item>
</style>

View File

@ -142,6 +142,12 @@
android:summary="@string/ShowUsernameInList_summary"
android:defaultValue="@bool/ShowUsernameInList_default"/>
<CheckBoxPreference
android:key="@string/ShowGroupnameInSearchResult_key"
android:title="@string/ShowGroupnameInSearchResult_title"
android:summary="@string/ShowGroupnameInSearchResult_resume"
android:defaultValue="@bool/ShowGroupnameInSearchResult_default"/>
<ListPreference
android:key="@string/list_size_key"
android:title="@string/list_size_title"

View File

@ -33,11 +33,16 @@ namespace keepass2android.view
private PwEntry _entry;
private readonly TextView _textView;
private readonly TextView _textviewDetails;
private readonly TextView _textgroupFullPath;
private int _pos;
private int? _defaultTextColor;
readonly bool _showDetail;
readonly bool _showGroupFullPath;
readonly bool _isSearchResult;
private const int MenuOpen = Menu.First;
private const int MenuDelete = MenuOpen + 1;
@ -66,7 +71,19 @@ namespace keepass2android.view
_textviewDetails = (TextView)ev.FindViewById(Resource.Id.entry_text_detail);
_textviewDetails.TextSize = PrefsUtil.GetListDetailTextSize(groupActivity);
_showDetail = PreferenceManager.GetDefaultSharedPreferences(groupActivity).GetBoolean(groupActivity.GetString(Resource.String.ShowUsernameInList_key), Resources.GetBoolean(Resource.Boolean.ShowUsernameInList_default));
_textgroupFullPath = (TextView)ev.FindViewById(Resource.Id.group_detail);
_textgroupFullPath.TextSize = PrefsUtil.GetListDetailTextSize(groupActivity);
_showDetail = PreferenceManager.GetDefaultSharedPreferences(groupActivity).GetBoolean(
groupActivity.GetString(Resource.String.ShowUsernameInList_key),
Resources.GetBoolean(Resource.Boolean.ShowUsernameInList_default));
_showGroupFullPath = PreferenceManager.GetDefaultSharedPreferences(groupActivity).GetBoolean(
groupActivity.GetString(Resource.String.ShowGroupnameInSearchResult_key),
Resources.GetBoolean(Resource.Boolean.ShowGroupnameInSearchResult_default));
_isSearchResult = _groupActivity is keepass2android.search.SearchResults;
PopulateView(ev, pw, pos);
@ -129,6 +146,24 @@ namespace keepass2android.view
_textviewDetails.Visibility = ViewStates.Visible;
}
if ( (!_showGroupFullPath) || (!_isSearchResult) ) {
_textgroupFullPath.Visibility = ViewStates.Gone;
}
else {
String groupDetail = pw.ParentGroup.GetFullPath();
var strGroupDetail = new SpannableString (groupDetail);
if (isExpired) {
strGroupDetail.SetSpan (new StrikethroughSpan (), 0, groupDetail.Length, SpanTypes.ExclusiveExclusive);
}
_textgroupFullPath.TextFormatted = strGroupDetail;
_textgroupFullPath.Visibility = ViewStates.Visible;
}
}
public void ConvertView(PwEntry pw, int pos)