diff --git a/src/keepass2android/GroupActivity.cs b/src/keepass2android/GroupActivity.cs index 13bb38ec..16d54ac8 100644 --- a/src/keepass2android/GroupActivity.cs +++ b/src/keepass2android/GroupActivity.cs @@ -43,8 +43,16 @@ namespace keepass2android //[MetaData("android.app.default_searchable",Value="keepass2android.search.SearchResults")] [IntentFilter(new[] { "android.intent.action.SEARCH" })] [MetaData("android.app.default_searchable", Value = "MaterialTest2.EntryEditActivity")] - [MetaData("android.app.searchable", Resource = "@xml/searchable_mattest")] - [IntentFilter(new string[]{"android.intent.action.SEARCH"})] +#if NoNet + [MetaData("android.app.searchable", Resource = "@xml/searchable_offline")] +#else +#if DEBUG + [MetaData("android.app.searchable", Resource = "@xml/searchable_debug")] +#else + [MetaData("android.app.searchable", Resource = "@xml/searchable")] +#endif +#endif + [IntentFilter(new string[]{"android.intent.action.SEARCH"})] [MetaData("android.app.searchable",Resource=AppNames.Searchable)] public class GroupActivity : GroupBaseActivity { diff --git a/src/keepass2android/Resources/xml/searchable.xml b/src/keepass2android/Resources/xml/searchable.xml index 13975ab2..cbb6b516 100644 --- a/src/keepass2android/Resources/xml/searchable.xml +++ b/src/keepass2android/Resources/xml/searchable.xml @@ -1,29 +1,10 @@ - \ No newline at end of file + android:searchSuggestSelection=" ?" + android:searchSuggestThreshold="2" /> \ No newline at end of file diff --git a/src/keepass2android/Resources/xml/searchable_debug.xml b/src/keepass2android/Resources/xml/searchable_debug.xml index 2d7c017b..cd715922 100644 --- a/src/keepass2android/Resources/xml/searchable_debug.xml +++ b/src/keepass2android/Resources/xml/searchable_debug.xml @@ -1,29 +1,10 @@ - \ No newline at end of file + android:searchSuggestSelection=" ?" + android:searchSuggestThreshold="2" /> \ No newline at end of file diff --git a/src/keepass2android/Resources/xml/searchable_mattest.xml b/src/keepass2android/Resources/xml/searchable_mattest.xml index 6418efa7..f9bb0dbb 100644 --- a/src/keepass2android/Resources/xml/searchable_mattest.xml +++ b/src/keepass2android/Resources/xml/searchable_mattest.xml @@ -3,10 +3,8 @@ android:label="@string/app_name" android:hint="@string/search_hint" android:searchSettingsDescription="Search database" - - android:searchMode="showSearchLabelAsBadge" - - android:searchSuggestAuthority="keepass2android.keepass2android_debug.SearchProvider" + android:searchMode="showSearchLabelAsBadge" + android:searchSuggestAuthority="kp2a.keepass2android_debug.SearchProvider" android:searchSuggestIntentAction="android.intent.action.VIEW" android:searchSuggestSelection=" ?" android:searchSuggestThreshold="2" /> \ No newline at end of file diff --git a/src/keepass2android/Resources/xml/searchable_offline.xml b/src/keepass2android/Resources/xml/searchable_offline.xml index 1f2a5e18..d759a892 100644 --- a/src/keepass2android/Resources/xml/searchable_offline.xml +++ b/src/keepass2android/Resources/xml/searchable_offline.xml @@ -1,29 +1,10 @@ - \ No newline at end of file + android:searchSuggestSelection=" ?" + android:searchSuggestThreshold="2" /> \ No newline at end of file diff --git a/src/keepass2android/search/SearchProvider.cs b/src/keepass2android/search/SearchProvider.cs index 11c2c950..8e38bea7 100644 --- a/src/keepass2android/search/SearchProvider.cs +++ b/src/keepass2android/search/SearchProvider.cs @@ -42,7 +42,7 @@ namespace keepass2android.search GetIcon, GetSuggestions } - public const String Authority = "keepass2android." + AppNames.PackagePart + ".SearchProvider"; + public const String Authority = "kp2a." + AppNames.PackagePart + ".SearchProvider"; private const string GetIconPathQuery = "get_icon"; private const string IconIdParameter = "IconId"; @@ -103,7 +103,16 @@ namespace keepass2android.search return null; } - public override ParcelFileDescriptor OpenFile(Android.Net.Uri uri, string mode) + + public static float convertDpToPixel(float dp, Context context) + { + Resources resources = context.Resources; + Android.Util.DisplayMetrics metrics = resources.DisplayMetrics; + float px = dp * metrics.Density; + return px; + } + + public override ParcelFileDescriptor OpenFile(Android.Net.Uri uri, string mode) { switch ((UriMatches)UriMatcher.Match(uri)) { @@ -119,7 +128,23 @@ namespace keepass2android.search ThreadPool.QueueUserWorkItem(state => { - iconDrawable.Bitmap.Compress(Bitmap.CompressFormat.Png, 100, outStream); + var original = iconDrawable.Bitmap; + Bitmap copy = Bitmap.CreateBitmap(original.Width, original.Height, original.GetConfig()); + Canvas copiedCanvas = new Canvas(copy); + copiedCanvas.DrawBitmap(original, 0f, 0f, null); + + var bitmap = copy; + float maxSize = convertDpToPixel(60, App.Context); + float scale = Math.Min(maxSize / bitmap.Width, maxSize / bitmap.Height); + var scaleWidth = (int)(bitmap.Width * scale); + var scaleHeight = (int)(bitmap.Height * scale); + var scaledBitmap = Bitmap.CreateScaledBitmap(bitmap, scaleWidth, scaleHeight, true); + Bitmap newRectBitmap = Bitmap.CreateBitmap((int)maxSize, (int)maxSize, Bitmap.Config.Argb8888); + + Canvas c = new Canvas(newRectBitmap); + c.DrawBitmap(scaledBitmap, (maxSize - scaledBitmap.Width) / 2.0f, (maxSize - scaledBitmap.Height) / 2.0f, null); + bitmap = newRectBitmap; + bitmap.Compress(Bitmap.CompressFormat.Png, 100, outStream); outStream.Close(); });