From 6f67d1057bf355c529bb30f1c0071a41324a188a Mon Sep 17 00:00:00 2001 From: Robert Eves Date: Sat, 17 Mar 2018 19:07:28 +0000 Subject: [PATCH 01/10] remove images and captions --- HertfordshireMercury/HertfordshireMercury/Models/Item.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HertfordshireMercury/HertfordshireMercury/Models/Item.cs b/HertfordshireMercury/HertfordshireMercury/Models/Item.cs index f4c7492..57c68bc 100644 --- a/HertfordshireMercury/HertfordshireMercury/Models/Item.cs +++ b/HertfordshireMercury/HertfordshireMercury/Models/Item.cs @@ -48,7 +48,7 @@ public string ArticleText List nodesToRemove = new List(); foreach (HtmlNode node in doc.DocumentNode.DescendantNodes()) { - if (node.Name.ToLower() == "form" || node.Name.ToLower() == "aside") + if (node.Name.ToLower() == "form" || node.Name.ToLower() == "aside" || node.Name.ToLower() == "figure") { nodesToRemove.Add(node); } From c50ec30a74c7024925811d330d60ee645ff50f3d Mon Sep 17 00:00:00 2001 From: Robert Eves Date: Sat, 17 Mar 2018 19:20:01 +0000 Subject: [PATCH 02/10] remove storage class --- .../Services/DataStore.cs | 2 -- .../HertfordshireMercury/Services/Storage.cs | 22 ------------------- 2 files changed, 24 deletions(-) delete mode 100644 HertfordshireMercury/HertfordshireMercury/Services/Storage.cs diff --git a/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs b/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs index 6cd704c..efdc99b 100644 --- a/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs +++ b/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs @@ -29,8 +29,6 @@ public DataStore() var feed = FeedReader.ReadFromString(feedSrc); - Storage.SaveTextDoc(feedSrc, "feed.txt"); - foreach (var item in feed.Items) { items.Add(new Item { Id = Guid.NewGuid().ToString(), Title = item.Title, Description = item.Description, PublishingDate = (DateTime)item.PublishingDate, Author = item.Author, Link = item.Link }); diff --git a/HertfordshireMercury/HertfordshireMercury/Services/Storage.cs b/HertfordshireMercury/HertfordshireMercury/Services/Storage.cs deleted file mode 100644 index 3c535f4..0000000 --- a/HertfordshireMercury/HertfordshireMercury/Services/Storage.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; - -namespace HertfordshireMercury.Services -{ - public static class Storage - { - private static string StoragePath => Environment.GetFolderPath(Environment.SpecialFolder.Personal); - - public static void SaveTextDoc(string DocSource, string Path) - { - string savePath = $"{StoragePath}/{Path}"; - - TextWriter textWriter = new StreamWriter(savePath); - textWriter.WriteLine(DocSource); - textWriter.Flush(); - textWriter.Close(); - } - } -} From cbb4a6a4c541cf145b4a5bc9c9be01d4caf0bde4 Mon Sep 17 00:00:00 2001 From: Robert Eves Date: Sat, 17 Mar 2018 19:20:43 +0000 Subject: [PATCH 03/10] remove from project --- .../HertfordshireMercury/HertfordshireMercury.projitems | 1 - 1 file changed, 1 deletion(-) diff --git a/HertfordshireMercury/HertfordshireMercury/HertfordshireMercury.projitems b/HertfordshireMercury/HertfordshireMercury/HertfordshireMercury.projitems index 81d43e0..af8623f 100644 --- a/HertfordshireMercury/HertfordshireMercury/HertfordshireMercury.projitems +++ b/HertfordshireMercury/HertfordshireMercury/HertfordshireMercury.projitems @@ -19,7 +19,6 @@ - From 062d4eb701d8143f7747fe694a078def16a1752c Mon Sep 17 00:00:00 2001 From: Robert Eves Date: Sat, 17 Mar 2018 19:31:40 +0000 Subject: [PATCH 04/10] move method to get item list to async task --- .../Services/DataStore.cs | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs b/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs index efdc99b..a69bec6 100644 --- a/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs +++ b/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs @@ -18,21 +18,6 @@ public class DataStore : IDataStore public DataStore() { items = new List(); - -#if DEBUG //use static feed saved in gist for testing - string feedUrl = "https://gist.githubusercontent.com/RobertEves92/85e22fbe847fc4fb08e1aa28851e3bdd/raw/ba25f9d2a9ef44a17071f2507ca20726f3832f74/gistfile1.txt"; -#else //use live feed from mercury for releases - string feedUrl = "https://www.hertfordshiremercury.co.uk/news/?service=rss"; -#endif - string feedSrc = NetServices.GetWebpageFromUrl(feedUrl); - feedSrc = Unescape.UnescapeHtml(feedSrc); - - var feed = FeedReader.ReadFromString(feedSrc); - - foreach (var item in feed.Items) - { - items.Add(new Item { Id = Guid.NewGuid().ToString(), Title = item.Title, Description = item.Description, PublishingDate = (DateTime)item.PublishingDate, Author = item.Author, Link = item.Link }); - } } public async Task AddItemAsync(Item item) @@ -66,6 +51,25 @@ public async Task GetItemAsync(string id) public async Task> GetItemsAsync(bool forceRefresh = false) { + foreach (Item item in items) + { + items.Remove(item); + } + +#if DEBUG //use static feed saved in gist for testing + string feedUrl = "https://gist.githubusercontent.com/RobertEves92/85e22fbe847fc4fb08e1aa28851e3bdd/raw/ba25f9d2a9ef44a17071f2507ca20726f3832f74/gistfile1.txt"; +#else //use live feed from mercury for releases + string feedUrl = "https://www.hertfordshiremercury.co.uk/news/?service=rss"; +#endif + string feedSrc = NetServices.GetWebpageFromUrl(feedUrl); + feedSrc = Unescape.UnescapeHtml(feedSrc); + + var feed = FeedReader.ReadFromString(feedSrc); + + foreach (var item in feed.Items) + { + items.Add(new Item { Id = Guid.NewGuid().ToString(), Title = item.Title, Description = item.Description, PublishingDate = (DateTime)item.PublishingDate, Author = item.Author, Link = item.Link }); + } return await Task.FromResult(items); } } From 41843c6b9516dee47538797a8885cbccaafd40da Mon Sep 17 00:00:00 2001 From: Robert Eves Date: Sat, 17 Mar 2018 19:33:41 +0000 Subject: [PATCH 05/10] remove clearing of items on download --- .../HertfordshireMercury/Services/DataStore.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs b/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs index a69bec6..db4ded0 100644 --- a/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs +++ b/HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs @@ -51,11 +51,6 @@ public async Task GetItemAsync(string id) public async Task> GetItemsAsync(bool forceRefresh = false) { - foreach (Item item in items) - { - items.Remove(item); - } - #if DEBUG //use static feed saved in gist for testing string feedUrl = "https://gist.githubusercontent.com/RobertEves92/85e22fbe847fc4fb08e1aa28851e3bdd/raw/ba25f9d2a9ef44a17071f2507ca20726f3832f74/gistfile1.txt"; #else //use live feed from mercury for releases From 2744f89e5ce89a79644366193f34716c202bfb62 Mon Sep 17 00:00:00 2001 From: Robert Eves Date: Sat, 17 Mar 2018 21:22:32 +0000 Subject: [PATCH 06/10] add share article button --- .../HertfordshireMercury/Views/ItemDetailPage.xaml | 1 + .../HertfordshireMercury/Views/ItemDetailPage.xaml.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml b/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml index 819f04b..2f8c980 100644 --- a/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml +++ b/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml @@ -4,6 +4,7 @@ x:Class="HertfordshireMercury.Views.ItemDetailPage" Title="{Binding Title}"> + diff --git a/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs b/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs index d1f3b9e..23434ce 100644 --- a/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs +++ b/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs @@ -41,5 +41,10 @@ private void ReadMore_Clicked(object sender, EventArgs e) { Device.OpenUri(new Uri(viewModel.Item.Link)); } + + private void Share_Clicked(object sender,EventArgs e) + { + throw new NotImplementedException(); + } } } \ No newline at end of file From 9263b45d550dea1409ee4343a22af2d5c316bd8f Mon Sep 17 00:00:00 2001 From: Robert Eves Date: Sat, 17 Mar 2018 21:27:23 +0000 Subject: [PATCH 07/10] add plugin share nuget package --- .../HertfordshireMercury.Android.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/HertfordshireMercury/HertfordshireMercury.Android/HertfordshireMercury.Android.csproj b/HertfordshireMercury/HertfordshireMercury.Android/HertfordshireMercury.Android.csproj index 5776ca1..f6b3d90 100644 --- a/HertfordshireMercury/HertfordshireMercury.Android/HertfordshireMercury.Android.csproj +++ b/HertfordshireMercury/HertfordshireMercury.Android/HertfordshireMercury.Android.csproj @@ -58,6 +58,9 @@ 1.1.1 + + 7.1.1 + From 66a9531f07409c38a52c82f91fb443137b2dfe1b Mon Sep 17 00:00:00 2001 From: Robert Eves Date: Sat, 17 Mar 2018 21:35:56 +0000 Subject: [PATCH 08/10] implemented open browser cross share with backup for if it is not supported --- .../HertfordshireMercury/Views/ItemDetailPage.xaml.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs b/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs index 23434ce..4cd54b9 100644 --- a/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs +++ b/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs @@ -6,6 +6,8 @@ using HertfordshireMercury.Models; using HertfordshireMercury.ViewModels; +using Plugin.Share; + namespace HertfordshireMercury.Views { [XamlCompilation(XamlCompilationOptions.Compile)] @@ -39,7 +41,10 @@ public ItemDetailPage() private void ReadMore_Clicked(object sender, EventArgs e) { - Device.OpenUri(new Uri(viewModel.Item.Link)); + if (CrossShare.IsSupported) + CrossShare.Current.OpenBrowser(viewModel.Item.Link); + else + Device.OpenUri(new Uri(viewModel.Item.Link)); } private void Share_Clicked(object sender,EventArgs e) From 93cb3f3ab805c175e611368eb8e9f3b24bf9c300 Mon Sep 17 00:00:00 2001 From: Robert Eves Date: Sat, 17 Mar 2018 21:39:46 +0000 Subject: [PATCH 09/10] implemented crossshare article sharing --- .../HertfordshireMercury/Views/ItemDetailPage.xaml.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs b/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs index 4cd54b9..1d9f636 100644 --- a/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs +++ b/HertfordshireMercury/HertfordshireMercury/Views/ItemDetailPage.xaml.cs @@ -49,7 +49,10 @@ private void ReadMore_Clicked(object sender, EventArgs e) private void Share_Clicked(object sender,EventArgs e) { - throw new NotImplementedException(); + if (CrossShare.IsSupported) + CrossShare.Current.Share(new Plugin.Share.Abstractions.ShareMessage { Title = viewModel.Item.Title, Text = viewModel.Item.Description, Url = viewModel.Item.Link }); + else + throw new Exception("CrossShare not supported"); } } } \ No newline at end of file From 41c024ee03d7f1cd12f6e80d0042936702e334ea Mon Sep 17 00:00:00 2001 From: Robert Eves Date: Sat, 17 Mar 2018 22:02:32 +0000 Subject: [PATCH 10/10] update android manifest for release --- .../HertfordshireMercury.Android/Properties/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HertfordshireMercury/HertfordshireMercury.Android/Properties/AndroidManifest.xml b/HertfordshireMercury/HertfordshireMercury.Android/Properties/AndroidManifest.xml index c58db40..cdbabe7 100644 --- a/HertfordshireMercury/HertfordshireMercury.Android/Properties/AndroidManifest.xml +++ b/HertfordshireMercury/HertfordshireMercury.Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - + \ No newline at end of file