Skip to content
This repository has been archived by the owner on Dec 20, 2018. It is now read-only.

Commit

Permalink
Merge branch 'release/0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertEves92 committed Mar 17, 2018
2 parents 18e08f2 + 41c024e commit bbd25fd
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
<PackageReference Include="CodeHollow.FeedReader">
<Version>1.1.1</Version>
</PackageReference>
<PackageReference Include="Plugin.Share">
<Version>7.1.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="2.5.0.122203" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="25.4.0.2" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="25.4.0.2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="0.1" package="com.roberteves.HertfordshireMercury.android" android:installLocation="auto">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.1.1" package="com.roberteves.HertfordshireMercury.android" android:installLocation="auto" android:versionCode="2">
<uses-sdk android:minSdkVersion="15" />
<application android:label="Hertfordshire Mercury"></application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Services\IDataStore.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Services\DataStore.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Services\NetServices.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Services\Storage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Services\Unescape.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\AboutViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\BaseViewModel.cs" />
Expand Down
2 changes: 1 addition & 1 deletion HertfordshireMercury/HertfordshireMercury/Models/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public string ArticleText
List<HtmlNode> nodesToRemove = new List<HtmlNode>();
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);
}
Expand Down
31 changes: 14 additions & 17 deletions HertfordshireMercury/HertfordshireMercury/Services/DataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,6 @@ public class DataStore : IDataStore<Item>
public DataStore()
{
items = new List<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);

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 });
}
}

public async Task<bool> AddItemAsync(Item item)
Expand Down Expand Up @@ -68,6 +51,20 @@ public async Task<Item> GetItemAsync(string id)

public async Task<IEnumerable<Item>> GetItemsAsync(bool forceRefresh = false)
{
#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);
}
}
Expand Down
22 changes: 0 additions & 22 deletions HertfordshireMercury/HertfordshireMercury/Services/Storage.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
x:Class="HertfordshireMercury.Views.ItemDetailPage"
Title="{Binding Title}">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Share" Clicked="Share_Clicked"/>
<ToolbarItem Text="View Site" Clicked="ReadMore_Clicked"/>
</ContentPage.ToolbarItems>
<ScrollView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using HertfordshireMercury.Models;
using HertfordshireMercury.ViewModels;

using Plugin.Share;

namespace HertfordshireMercury.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
Expand Down Expand Up @@ -39,7 +41,18 @@ 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)
{
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");
}
}
}

0 comments on commit bbd25fd

Please sign in to comment.