Skip to content

Commit

Permalink
UWP Download Location Fixed.
Browse files Browse the repository at this point in the history
1.) UWP download location fixed.
2.) BadgeLogo fixed.
3.) Added references for Ads in UWP project. (Doesn't work tho).

Know Issues :
Setting up AdControlView in UWP throws `System.InvalidOperationException: 'Cannot assign a native control without an Element; Renderer unbound and/or disposed. Please consult Xamarin.Forms renderers for reference implementation of OnElementChanged.'`.

Need to fix that.
  • Loading branch information
Xonshiz committed Mar 24, 2019
1 parent d3d3560 commit 4c121bd
Show file tree
Hide file tree
Showing 21 changed files with 143 additions and 39 deletions.
12 changes: 10 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
- Initial Code Commit For CoManga [2019.03.05]
- Added download location for UWP [2019.03.11]
- Initial Code Commit For CoManga. [2019.03.05]
- Added download location for UWP. [2019.03.11]
- UWP download location fixed. [2019.03.24]
- BadgeLogo fixed. [2019.03.24]
- Added references for Ads in UWP project. (Doesn't work tho). [2019.03.24]

Know Issues :
Setting up AdControlView in UWP throws `System.InvalidOperationException: 'Cannot assign a native control without an Element; Renderer unbound and/or disposed. Please consult Xamarin.Forms renderers for reference implementation of OnElementChanged.'`.

Need to fix that.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ If you're on iOS, then you're compiling the project and the files will be stored
You should get your downloaded items there.

#### UWP
Getting the permissions is a little tricky in UWP. I've literally tried a lot of different things and couldn't get it to work. So, you'll have to work hard to get these downloaded files. You can find them in this location :
`C:\Users\{Your User Name}\AppData\Local\Packages\8c5bdaa1-7509-4aca-bd99-321c57de3c9f_0b312jg1at2fy\LocalState\CoManga`
You can find your downloaded content in the `"Downloads"` folder undeder the folder named "CoManga".


# Why Is It Not On Application Stores?
Expand Down
10 changes: 10 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
- Initial Code Commit For CoManga [2019.03.05]
- Added download location for UWP [2019.03.11]
- Initial Code Commit For CoManga. [2019.03.05]
- Added download location for UWP. [2019.03.11]
- UWP download location fixed. [2019.03.24]
- BadgeLogo fixed. [2019.03.24]
- Added references for Ads in UWP project. (Doesn't work tho). [2019.03.24]

Know Issues :
Setting up AdControlView in UWP throws `System.InvalidOperationException: 'Cannot assign a native control without an Element; Renderer unbound and/or disposed. Please consult Xamarin.Forms renderers for reference implementation of OnElementChanged.'`.

Need to fix that.
5 changes: 1 addition & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ You should get your downloaded items there.
UWP
^^^

Getting the permissions is a little tricky in UWP. I've literally tried
a lot of different things and couldn't get it to work. So, you'll have
to work hard to get these downloaded files. You can find them in this
location : ``C:\Users\{Your User Name}\AppData\Local\Packages\8c5bdaa1-7509-4aca-bd99-321c57de3c9f_0b312jg1at2fy\LocalState\CoManga``
You can find your downloaded content in the `"Downloads"` folder undeder the folder named "CoManga".

Why Is It Not On Application Stores?
====================================
Expand Down
3 changes: 3 additions & 0 deletions src/comic_dl/comic_dl.Android/comic_dl.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
<PackageReference Include="HtmlAgilityPack">
<Version>1.9.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.Services.Store.SDK">
<Version>10.1705.16001</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.1</Version>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/comic_dl/comic_dl.Android/comic_dl.Android.csproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SelectedDevice>Xiaomi Mi A1</SelectedDevice>
<SelectedDevice>Android_Accelerated_x86_Oreo</SelectedDevice>
<DefaultDevice>Android_Accelerated_x86_Oreo</DefaultDevice>
<AndroidDesignerPreferredTheme>Theme.DeviceDefault.NoActionBar.Fullscreen</AndroidDesignerPreferredTheme>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO;
using System.Linq;
using System.Text;

using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.OS;
Expand Down Expand Up @@ -53,22 +53,22 @@ public bool CheckExisingFile(string fileAddress)
return false;
}

public bool CreateFile(string directoryName, byte[] contentToWrite)
public Task<bool> CreateFile(string directoryName, byte[] contentToWrite)
{
var filePath = Path.Combine(documentBasePath, directoryName);
if (!File.Exists(filePath))
{
try
{
File.WriteAllBytes(directoryName, contentToWrite);
return true;
return Task.FromResult(true);
}
catch (Exception)
{
return false;
return Task.FromResult(false);
}
}
return false;
return Task.FromResult(false);
}
}
}
Binary file modified src/comic_dl/comic_dl.UWP/Assets/BadgeLogo.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/comic_dl/comic_dl.UWP/Assets/BadgeLogo.scale-125.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/comic_dl/comic_dl.UWP/Assets/BadgeLogo.scale-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/comic_dl/comic_dl.UWP/Assets/BadgeLogo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/comic_dl/comic_dl.UWP/Assets/BadgeLogo.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion src/comic_dl/comic_dl.UWP/comic_dl.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="customRenderer\AdViewRenderer.cs" />
<Compile Include="dependencyServices\DirectoryHelper.cs" />
<Compile Include="dependencyServices\SQLiteDb.cs" />
<Compile Include="MainPage.xaml.cs">
Expand Down Expand Up @@ -189,6 +190,9 @@
<PackageReference Include="HtmlAgilityPack">
<Version>1.9.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.Services.Store.SDK">
<Version>10.1705.16001</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.1</Version>
</PackageReference>
Expand All @@ -207,8 +211,14 @@
<Name>comic_dl</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="customRenderer\" />
<SDKReference Include="Microsoft.Advertising.Xaml, Version=10.0">
<Name>Microsoft Advertising SDK for XAML</Name>
</SDKReference>
<SDKReference Include="Microsoft.VCLibs, Version=14.0">
<Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>
</SDKReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
Expand Down
55 changes: 55 additions & 0 deletions src/comic_dl/comic_dl.UWP/customRenderer/AdViewRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Advertising.Ads;
using Microsoft.Advertising.WinRT.UI;
using Windows.System.Profile;

[assembly: ExportRenderer(typeof(comic_dl.Controls.AdControlView), typeof(comic_dl.UWP.customRenderer.AdViewRenderer))]
namespace comic_dl.UWP.customRenderer
{
#pragma warning disable CS0618 // Type or member is obsolete
public class AdViewRenderer : ViewRenderer<Controls.AdControlView, AdControl>
{
string bannerId = "1100041955";
AdControl adView;
string applicationID = "9n81f8b5ww93";
void CreateNativeAdControl()
{
if (adView != null)
return;

var width = 300;
var height = 50;
if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Desktop")
{
width = 728;
height = 90;
}
// Setup your BannerView, review AdSizeCons class for more Ad sizes.
adView = new AdControl
{
ApplicationId = applicationID,
AdUnitId = bannerId,
HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center,
VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Bottom,
Height = height,
Width = width
};

}

protected override void OnElementChanged(ElementChangedEventArgs<Controls.AdControlView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
CreateNativeAdControl();
//SetNativeControl(adView);
}
}
}
#pragma warning restore CS0618 // Type or member is obsolete
}
39 changes: 28 additions & 11 deletions src/comic_dl/comic_dl.UWP/dependencyServices/DirectoryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using Xamarin.Forms;

[assembly: Dependency(typeof(DirectoryHelper))]
Expand Down Expand Up @@ -48,23 +49,39 @@ public bool CheckExisingFile(string fileAddress)
return false;
}

public bool CreateFile(string directoryName, byte[] contentToWrite)
public async Task<bool> CreateFile(string directoryName, byte[] contentToWrite)
{
//var filePath = Path.Combine(documentBasePath, directoryName);
var filePath = Windows.Storage.DownloadsFolder.CreateFileAsync(directoryName);
if (!File.Exists(Convert.ToString(filePath)))
List<string> fileNames = directoryName.Split('/').ToList();
string downloadType = fileNames[1];
string comicName = fileNames[2];
string comicChapter = fileNames[3];
string comicFileName = fileNames[4];
StorageFile destinationFile;
StorageFolder downloadsFolder;
try
{
try
downloadsFolder = await DownloadsFolder.CreateFolderAsync(downloadType + @"\" + comicName + @"\" + comicChapter + @"\");
string folderToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(downloadsFolder);
ApplicationData.Current.LocalSettings.Values["folderToken"] = folderToken;
destinationFile = await downloadsFolder.CreateFileAsync(comicFileName, CreationCollisionOption.ReplaceExisting);

await Windows.Storage.FileIO.WriteBytesAsync(destinationFile, contentToWrite);
return true;
// File.WriteAllBytes(destinationFile.Path, contentToWrite);
}
catch (Exception ex)
{
if (ApplicationData.Current.LocalSettings.Values["folderToken"] != null)
{
File.WriteAllBytes(directoryName, contentToWrite);
string token = ApplicationData.Current.LocalSettings.Values["folderToken"].ToString();
downloadsFolder = await Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.GetFolderAsync(token);
destinationFile = await downloadsFolder.CreateFileAsync(comicFileName, CreationCollisionOption.ReplaceExisting);
//File.WriteAllBytes(destinationFile.Path, contentToWrite);
await Windows.Storage.FileIO.WriteBytesAsync(destinationFile, contentToWrite);
return true;
}
catch (Exception)
{
return false;
}
return false;
}
return false;
}
}
}
14 changes: 8 additions & 6 deletions src/comic_dl/comic_dl.iOS/comic_dl.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@
<PackageReference Include="HtmlAgilityPack">
<Version>1.9.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.Services.Store.SDK">
<Version>10.1705.16001</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.1</Version>
</PackageReference>
Expand All @@ -643,16 +646,15 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="customRenderer\" />
<Folder Include="images\" />
<Folder Include="Assets.xcassets\ic_comic.imageset\" />
<Folder Include="Assets.xcassets\ic_manga.imageset\" />
<Folder Include="Assets.xcassets\ic_ongoing.imageset\" />
<Folder Include="Assets.xcassets\ic_completed.imageset\" />
<Folder Include="Assets.xcassets\ic_latest.imageset\" />
<Folder Include="Assets.xcassets\ic_whatshot.imageset\" />
<Folder Include="Assets.xcassets\ic_download.imageset\" />
<Folder Include="Assets.xcassets\ic_latest.imageset\" />
<Folder Include="Assets.xcassets\ic_manga.imageset\" />
<Folder Include="Assets.xcassets\ic_ongoing.imageset\" />
<Folder Include="Assets.xcassets\ic_settings.imageset\" />
<Folder Include="Assets.xcassets\ic_whatshot.imageset\" />
<Folder Include="images\" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\ic_completed%401x.png" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using UIKit;
using Xamarin.Forms;
using comic_dl.interace;
using System.Threading.Tasks;

[assembly: Dependency(typeof(DirectoryHelper))]
namespace comic_dl.iOS
Expand Down Expand Up @@ -47,22 +48,22 @@ public bool CheckExisingFile(string fileAddress)
return false;
}

public bool CreateFile(string directoryName, byte[] contentToWrite)
public Task<bool> CreateFile(string directoryName, byte[] contentToWrite)
{
var filePath = documentBasePath + directoryName;
if (!File.Exists(filePath))
{
try
{
File.WriteAllBytes(directoryName, contentToWrite);
return true;
return Task.FromResult(true);
}
catch (Exception)
{
return false;
return Task.FromResult(false);
}
}
return false;
return Task.FromResult(false);
}
}
}
2 changes: 1 addition & 1 deletion src/comic_dl/comic_dl/_comic/downloader/ComicDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task<bool> FilesDownloader(List<string> listOfUrl, string comicName
if (contents == null) // If there's nothing, just move onto the next loop.
continue;

bool isFileDownloaded = DependencyService.Get<IDirectory>().CreateFile(filePath, contents);
bool isFileDownloaded = await DependencyService.Get<IDirectory>().CreateFile(filePath, contents);


if (!isFileDownloaded)
Expand Down
2 changes: 1 addition & 1 deletion src/comic_dl/comic_dl/_manga/downloader/Downloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task<bool> FilesDownloader(List<string> listOfUrl, string mangaName
if (contents == null) // If there's nothing, just move onto the next loop.
continue;

bool isFileDownloaded = DependencyService.Get<IDirectory>().CreateFile(filePath, contents);
bool isFileDownloaded = await DependencyService.Get<IDirectory>().CreateFile(filePath, contents);


if (!isFileDownloaded)
Expand Down
1 change: 1 addition & 0 deletions src/comic_dl/comic_dl/comic_dl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="CardsView" Version="2.0.3" />
<PackageReference Include="HtmlAgilityPack" Version="1.9.0" />
<PackageReference Include="Microsoft.Services.Store.SDK" Version="10.1705.16001" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Refit" Version="4.6.90" />
<PackageReference Include="sqlite-net-pcl" Version="1.5.231" />
Expand Down
3 changes: 2 additions & 1 deletion src/comic_dl/comic_dl/interace/IDirectory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace comic_dl.interace
{
Expand All @@ -9,6 +10,6 @@ public interface IDirectory
string GetBasePath();
string CreateDirectory(string directoryName);
bool CheckExisingFile(string filePath);
bool CreateFile(string directoryName, byte[] contentToWrite);
Task<bool> CreateFile(string directoryName, byte[] contentToWrite);
}
}

0 comments on commit 4c121bd

Please sign in to comment.