summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Marinho <me@ruimarinho.net>2016-05-25 14:50:21 +0100
committerRui Marinho <me@ruimarinho.net>2016-05-25 14:50:21 +0100
commitc502f47980882e61402f77a55236653a22f706ab (patch)
treee2465e2bb273825b5a65ff6eebfaf58ae8db9549
parentf1b61260959983a099430c02318fc4fc3aa9d9c4 (diff)
downloadxamarin-forms-c502f47980882e61402f77a55236653a22f706ab.tar.gz
xamarin-forms-c502f47980882e61402f77a55236653a22f706ab.tar.bz2
xamarin-forms-c502f47980882e61402f77a55236653a22f706ab.zip
[Android] Implement the AppIndexProvider on non-AppCompact, fix KeyValues on AppLinkEntry (#166)
* [Android] Set AppIndexingProvider on non AppCompact activity * [Core] Fix AppLinkEntry KeyValues
-rw-r--r--Xamarin.Forms.Core.UnitTests/AppLinkEntryTests.cs42
-rw-r--r--Xamarin.Forms.Core.UnitTests/Xamarin.Forms.Core.UnitTests.csproj1
-rw-r--r--Xamarin.Forms.Core/AppLinkEntry.cs12
-rw-r--r--Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs2
4 files changed, 56 insertions, 1 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/AppLinkEntryTests.cs b/Xamarin.Forms.Core.UnitTests/AppLinkEntryTests.cs
new file mode 100644
index 00000000..0a5c5a8b
--- /dev/null
+++ b/Xamarin.Forms.Core.UnitTests/AppLinkEntryTests.cs
@@ -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());
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UnitTests/Xamarin.Forms.Core.UnitTests.csproj b/Xamarin.Forms.Core.UnitTests/Xamarin.Forms.Core.UnitTests.csproj
index e8eeaba4..27fc07ee 100644
--- a/Xamarin.Forms.Core.UnitTests/Xamarin.Forms.Core.UnitTests.csproj
+++ b/Xamarin.Forms.Core.UnitTests/Xamarin.Forms.Core.UnitTests.csproj
@@ -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">
diff --git a/Xamarin.Forms.Core/AppLinkEntry.cs b/Xamarin.Forms.Core/AppLinkEntry.cs
index 6942aa10..154b9691 100644
--- a/Xamarin.Forms.Core/AppLinkEntry.cs
+++ b/Xamarin.Forms.Core/AppLinkEntry.cs
@@ -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));
@@ -33,7 +40,10 @@ namespace Xamarin.Forms
set { SetValue(IsLinkActiveProperty, value); }
}
- public IDictionary<string, string> KeyValues => new Dictionary<string, string>();
+ public IDictionary<string, string> KeyValues
+ {
+ get { return keyValues; }
+ }
public ImageSource Thumbnail
{
diff --git a/Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs b/Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs
index 31225f9f..ca862d1c 100644
--- a/Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs
+++ b/Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs
@@ -100,6 +100,8 @@ namespace Xamarin.Forms.Platform.Android
if (application == null)
throw new ArgumentNullException("application");
+ (application as IApplicationController)?.SetAppIndexingProvider(new AndroidAppIndexProvider(this));
+
_application = application;
Xamarin.Forms.Application.Current = application;