Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions LeagueOfNews.Core/LeagueOfNews.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</PackageReference>
<PackageReference Include="HtmlAgilityPack" Version="1.11.17" />
<PackageReference Include="MvvmCross" Version="6.4.2" />
<PackageReference Include="PropertyChanged.Fody" Version="3.2.2" />
<PackageReference Include="PropertyChanged.Fody" Version="3.2.3" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.6.0-preview.18571.3" />
<PackageReference Include="Xamarin.Essentials" Version="1.4.0-pre" />
<PackageReference Include="Xamarin.Essentials" Version="1.4.0-pre2" />
<PackageReference Include="Xamarin.FFImageLoading" Version="2.4.11.982" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions LeagueOfNews.Forms.Android/LeagueOfNews.Forms.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@
<Version>1.0.0-rc1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Essentials">
<Version>1.4.0-pre</Version>
<Version>1.4.0-pre2</Version>
</PackageReference>
<PackageReference Include="Xamarin.FFImageLoading.Forms">
<Version>2.4.11.982</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.1.0-preview06" />
<PackageReference Include="Xamarin.Forms">
<Version>4.4.0.991440</Version>
<Version>4.4.0.991477</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms.Visual.Material">
<Version>4.4.0.991440</Version>
<Version>4.4.0.991477</Version>
</PackageReference>
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0-preview06" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0-rc1" />
Expand Down
12,573 changes: 6,311 additions & 6,262 deletions LeagueOfNews.Forms.Android/Resources/Resource.designer.cs

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions LeagueOfNews.Forms/LeagueOfNews.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<PackageReference Include="MvvmCross" Version="6.4.2" />
<PackageReference Include="MvvmCross.Forms" Version="6.4.2" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.6.0-preview.18571.3" />
<PackageReference Include="Xamarin.Essentials" Version="1.4.0-pre" />
<PackageReference Include="Xamarin.Essentials" Version="1.4.0-pre2" />
<PackageReference Include="Xamarin.FFImageLoading.Forms" Version="2.4.11.982" />
<PackageReference Include="Xamarin.Forms" Version="4.4.0.991440" />
<PackageReference Include="Xamarin.Forms.Visual.Material" Version="4.4.0.991440" />
<PackageReference Include="Xamarin.Forms" Version="4.4.0.991477" />
<PackageReference Include="Xamarin.Forms.Visual.Material" Version="4.4.0.991477" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@
<ActivityIndicator Style="{StaticResource ActivityIndicator}"/>
</Grid>
</CollectionView.Footer>
<CollectionView.EmptyView>
<Grid>
<ActivityIndicator Style="{StaticResource ActivityIndicator}"/>
</Grid>
</CollectionView.EmptyView>
</CollectionView>
</RefreshView>
<ActivityIndicator IsVisible="{Binding IsLoading}" Style="{StaticResource ActivityIndicator}"/>
</Grid>
</views:MvxContentPage.Content>
</views:MvxContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace LeagueOfNews.Forms.Views.CategoryViews
{
[MvxMasterDetailPagePresentation(MasterDetailPosition.Detail, WrapInNavigationPage = true, NoHistory = false)]
[MvxMasterDetailPagePresentation(MasterDetailPosition.Detail, WrapInNavigationPage = true, NoHistory = true)]
public partial class TabbedRootPage : MvxTabbedPage<TabbedRootViewModel>
{
public TabbedRootPage() => InitializeComponent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@
<ActivityIndicator Style="{StaticResource ActivityIndicator}"/>
</Grid>
</CollectionView.Footer>
<CollectionView.EmptyView>
<Grid>
<ActivityIndicator Style="{StaticResource ActivityIndicator}"/>
</Grid>
</CollectionView.EmptyView>
</CollectionView>
</RefreshView>
<ActivityIndicator IsVisible="{Binding IsLoading}" Style="{StaticResource ActivityIndicator}"/>
</Grid>
</views:MvxContentPage.Content>
</views:MvxContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace LeagueOfNews.Forms.Views.NoCategoryViews
{
[MvxMasterDetailPagePresentation(MasterDetailPosition.Detail, NoHistory = false)]
[MvxMasterDetailPagePresentation(MasterDetailPosition.Detail, NoHistory = true)]
public partial class NewsfeedListView : MvxContentPage<NewsfeedListViewModel>
{
public NewsfeedListView() => InitializeComponent();
Expand Down
2 changes: 1 addition & 1 deletion LeagueOfNews.Forms/Views/SettingsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace LeagueOfNews.Forms.Views
{
[MvxMasterDetailPagePresentation(MasterDetailPosition.Detail, NoHistory = false)]
[MvxMasterDetailPagePresentation(MasterDetailPosition.Detail, NoHistory = true)]
public partial class SettingsView : MvxContentPage<SettingsViewModel>
{
public SettingsView() => InitializeComponent();
Expand Down
1 change: 1 addition & 0 deletions LeagueOfNews.Model/Newsfeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public class Newsfeed
public string Title { get; set; }
public string ShortDescription { get; set; }
public string ImageUrl { get; set; }
public string WebsiteName { get; set; }
}
}
1 change: 1 addition & 0 deletions LeagueOfNews.Model/Website.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Website
public string Name { get; set; }
public IEnumerable<Website> Subpages { get; set; }
public string Url { get; set; }
public string Icon { get; set; }
public string ParserName { get; set; }
}
}
29 changes: 29 additions & 0 deletions LeagueOfNews.Utils/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace LeagueOfNews.Utils
{
public static class Extensions
{
public static Dictionary<string, string> ToDictionary(this object objectToConvert)
{
return objectToConvert.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.ToDictionary(prop => prop.Name, prop => prop.GetValue(objectToConvert, null).ToString());
}

public static T FromDictionary<T>(this IDictionary<string, string> dictionaryToConvert) where T : new()
{
T target = new T();
foreach (KeyValuePair<string, string> item in dictionaryToConvert)
{
Type type = target.GetType();
PropertyInfo prop = type.GetProperty(item.Key);
prop.SetValue(target, item.Value, null);
}
return target;
}
}
}
7 changes: 7 additions & 0 deletions LeagueOfNews.Utils/LeagueOfNews.Utils.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

</Project>
5 changes: 1 addition & 4 deletions LeagueOfNews.WebApi/Controllers/AppConfigController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ namespace LeagueOfNews.WebApi.Controllers
public class AppConfigController : ControllerBase
{
private readonly IAppConfigService _appConfigService;
public AppConfigController(IAppConfigService appConfigService)
{
_appConfigService = appConfigService;
}
public AppConfigController(IAppConfigService appConfigService) => _appConfigService = appConfigService;
[HttpGet]
public AppConfig Get() => _appConfigService.AppConfig;
}
Expand Down
17 changes: 17 additions & 0 deletions LeagueOfNews.WebApi/LeagueOfNews.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@

<ItemGroup>
<ProjectReference Include="..\LeagueOfNews.Model\LeagueOfNews.Model.csproj" />
<ProjectReference Include="..\LeagueOfNews.Utils\LeagueOfNews.Utils.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\icons\ios\" />
</ItemGroup>

<ItemGroup>
<Content Update="wwwroot\icons\android\dev.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\icons\android\official.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\icons\android\surrender.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>


Expand Down
6 changes: 6 additions & 0 deletions LeagueOfNews.WebApi/Services/NewPostsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public NewPostsService(IPushNotificationService pushNotificationService, IOption

public async void Execute(object source, ElapsedEventArgs e)
{

/* Newsfeed lastPost = (await _newsfeedService.GetNewsfeeds(0, 1)).First();
lastPost.WebsiteName = _appConfig.Websites.First().Name;
await _pushNotificationService.PushNotification(lastPost);*/

foreach (Website website in _appConfig.Websites)
{
Newsfeed lastPost = (await _newsfeedService.GetNewsfeeds(website.Id, 1)).First();
Expand All @@ -34,6 +39,7 @@ public async void Execute(object source, ElapsedEventArgs e)
if (lastPost.UrlToNewsfeed != lastUrl)
{
_lastPosts[website.Id] = lastPost.UrlToNewsfeed;
lastPost.WebsiteName = website.Name;
await _pushNotificationService.PushNotification(lastPost);
}
}
Expand Down
10 changes: 2 additions & 8 deletions LeagueOfNews.WebApi/Services/PushNotificationService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using FirebaseAdmin.Messaging;
using LeagueOfNews.Model;
using LeagueOfNews.Utils;
using LeagueOfNews.WebApi.Services.Interfaces;

namespace LeagueOfNews.WebApi.Services
Expand All @@ -13,13 +13,7 @@ public async Task PushNotification(Newsfeed newsfeed)
{
Message message = new Message()
{
Data = new Dictionary<string, string>()
{
{ "title", newsfeed.Title },
{ "body", newsfeed.ShortDescription },
{ "icon", newsfeed.ImageUrl },
{ "url", newsfeed.UrlToNewsfeed },
},
Data = newsfeed.ToDictionary(),
Topic = "News"
};

Expand Down
11 changes: 11 additions & 0 deletions LeagueOfNews.WebApi/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.IO;
using Autofac;
using FirebaseAdmin;
using Google.Apis.Auth.OAuth2;
Expand All @@ -7,6 +8,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using ServiceIterator;
Expand All @@ -25,6 +27,7 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerGen(c =>
{
c.CustomOperationIds(e => $"{e.ActionDescriptor.RouteValues["controller"]}_{e.HttpMethod}");
c.SwaggerDoc("v1", new OpenApiInfo { Title = "League of news web api", Version = "v1" });
});

Expand All @@ -47,6 +50,14 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseServicesIterator();

app.UseFileServer(new FileServerOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "icons")),
RequestPath = "/icons",
EnableDirectoryBrowsing = true
});

app.UseCors(builder =>
{
builder.AllowAnyOrigin();
Expand Down
9 changes: 6 additions & 3 deletions LeagueOfNews.WebApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
"Websites": [
{
"Id": "0",
"Name": "League of Legends Official",
"Name": "Official site",
"Subpages": null,
"Url": "https://eune.leagueoflegends.com/en/news",
"ParserName" : "Official"
"Icon": "official",
"ParserName": "Official"
},
{
"Id": "1",
"Name": "Surrender@20",
"ParserName": "Surrender",
"Icon": "surrender",
"Subpages": [
{
"Id": "2",
Expand Down Expand Up @@ -70,8 +72,9 @@
"Id": "7",
"Name": "Dev Corner",
"ParserName": "Dev",
"Icon": "dev",
"Subpages": null,
"Url": "https://boards.na.leagueoflegends.com/api/A7LBtoKc/discussions?sort_type=recent"
"Url": "https://boards.na.leagueoflegends.com/api/A7LBtoKc/discussions?sort_type=recent"
}
]
}
Expand Down
Binary file added LeagueOfNews.WebApi/wwwroot/icons/android/dev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading