Skip to content

Commit

Permalink
[Android] Implement the AppIndexProvider on non-AppCompact, fix KeyVa…
Browse files Browse the repository at this point in the history
…lues on AppLinkEntry (xamarin#166)

* [Android] Set AppIndexingProvider on non AppCompact activity

* [Core] Fix AppLinkEntry KeyValues
  • Loading branch information
rmarinho committed May 25, 2016
1 parent f1b6126 commit c502f47
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
42 changes: 42 additions & 0 deletions Xamarin.Forms.Core.UnitTests/AppLinkEntryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using NUnit.Framework;

namespace Xamarin.Forms.Core.UnitTests
{
[TestFixture]
public class AppLinkEntryTests : BaseTestFixture
{

[Test]
public void KeyValuesTest()
{
var entry = new AppLinkEntry();

entry.KeyValues.Add("contentType", "GalleryPage");
entry.KeyValues.Add("companyName", "Xamarin");
Assert.AreEqual(entry.KeyValues.Count, 2);
}


[Test]
public void FromUriTest()
{
var uri = new Uri("http://foo.com");

var entry = AppLinkEntry.FromUri(uri);

Assert.AreEqual(uri, entry.AppLinkUri);
}

[Test]
public void ToStringTest()
{
var str = "http://foo.com";
var uri = new Uri(str);

var entry = new AppLinkEntry { AppLinkUri = uri };

Assert.AreEqual(uri.ToString(), entry.ToString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
<Compile Include="MultiTriggerTests.cs" />
<Compile Include="TriggerTests.cs" />
<Compile Include="PinchGestureRecognizerTests.cs" />
<Compile Include="AppLinkEntryTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xamarin.Forms.Core\Xamarin.Forms.Core.csproj">
Expand Down
12 changes: 11 additions & 1 deletion Xamarin.Forms.Core/AppLinkEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ namespace Xamarin.Forms
{
public class AppLinkEntry : Element, IAppLinkEntry
{
readonly Dictionary<string, string> keyValues;

public AppLinkEntry()
{
keyValues = new Dictionary<string, string>();
}

public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(AppLinkEntry), default(string));

public static readonly BindableProperty DescriptionProperty = BindableProperty.Create(nameof(Description), typeof(string), typeof(AppLinkEntry), default(string));
Expand Down Expand Up @@ -33,7 +40,10 @@ public bool IsLinkActive
set { SetValue(IsLinkActiveProperty, value); }
}

public IDictionary<string, string> KeyValues => new Dictionary<string, string>();
public IDictionary<string, string> KeyValues
{
get { return keyValues; }
}

public ImageSource Thumbnail
{
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ protected void LoadApplication(Application application)
if (application == null)
throw new ArgumentNullException("application");

(application as IApplicationController)?.SetAppIndexingProvider(new AndroidAppIndexProvider(this));

_application = application;
Xamarin.Forms.Application.Current = application;

Expand Down

0 comments on commit c502f47

Please sign in to comment.