Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default(string) to string.Empty, updated for Android 9 SDK and enabled support for http #108

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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
6 changes: 5 additions & 1 deletion DownloadManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DownloadExample.Droid", "Sa
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DownloadExample.iOS", "Sample\iOS\DownloadExample.iOS.csproj", "{3BFA0D23-9172-46AF-BF9A-84F1E35BB969}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DownloadExample.UWP", "Sample\UWP\UWP.csproj", "{D32EDF26-94F4-4F80-B26C-CA250A3F6D7D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWP", "Sample\UWP\UWP.csproj", "{D32EDF26-94F4-4F80-B26C-CA250A3F6D7D}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this was supposed to go in here 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have UWP installed on the computer I opened it on.
So I should probably not included changes in sln for the pull.

EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DownloadExample", "Sample\DownloadExample\DownloadExample.csproj", "{FEE6A3A2-9CDD-473C-8587-6C13241BD03A}"
EndProject
Expand Down Expand Up @@ -271,6 +271,7 @@ Global
{7F416A1F-D4DD-436E-A903-DF2FC75E623E}.AppStore|x86.Build.0 = Debug|Any CPU
{7F416A1F-D4DD-436E-A903-DF2FC75E623E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F416A1F-D4DD-436E-A903-DF2FC75E623E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F416A1F-D4DD-436E-A903-DF2FC75E623E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{7F416A1F-D4DD-436E-A903-DF2FC75E623E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7F416A1F-D4DD-436E-A903-DF2FC75E623E}.Debug|ARM.Build.0 = Debug|Any CPU
{7F416A1F-D4DD-436E-A903-DF2FC75E623E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -414,6 +415,9 @@ Global
{D32EDF26-94F4-4F80-B26C-CA250A3F6D7D} = {11FE7FBB-8560-4D89-90F5-F218CF18A879}
{FEE6A3A2-9CDD-473C-8587-6C13241BD03A} = {11FE7FBB-8560-4D89-90F5-F218CF18A879}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this change for? What does it help - what does it do?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't change anything regarding this, VS 2017 v15.9.9.9 is the one to blame.
It could be added when I set the Android project to deploy.

SolutionGuid = {D7B718F5-272F-49BC-80BA-53BA5D5F417A}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
$0.TextStylePolicy = $1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void UpdateFileProperties (ICursor cursor, DownloadFileImplementation dow
switch ((DownloadStatus)cursor.GetInt (cursor.GetColumnIndex (Android.App.DownloadManager.ColumnStatus))) {
case DownloadStatus.Successful:
downloadFile.DestinationPathName = cursor.GetString(cursor.GetColumnIndex("local_uri"));
downloadFile.StatusDetails = default(string);
downloadFile.StatusDetails = string.Empty;
downloadFile.Status = DownloadFileStatus.COMPLETED;
RemoveFile (downloadFile);
break;
Expand Down Expand Up @@ -236,12 +236,12 @@ public void UpdateFileProperties (ICursor cursor, DownloadFileImplementation dow
break;

case DownloadStatus.Pending:
downloadFile.StatusDetails = default(string);
downloadFile.StatusDetails = string.Empty;
downloadFile.Status = DownloadFileStatus.PENDING;
break;

case DownloadStatus.Running:
downloadFile.StatusDetails = default(string);
downloadFile.StatusDetails = string.Empty;
downloadFile.Status = DownloadFileStatus.RUNNING;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<DevInstrumentationEnabled>True</DevInstrumentationEnabled>
<TargetFrameworkVersion>v7.0</TargetFrameworkVersion>
<AndroidTlsProvider></AndroidTlsProvider>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this not require everyone, using this package, to upgrade his app to at least this version? I'm sometimes quite concerned to do this, not to lock people in a position where they're forced to update if they want to continue using my plugin.

I haven't been involved in the Xamarin development lately and don't know their best practices. Please write your comment here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno best practices for this, but I have checked the docs: https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/android-api-levels?tabs=windows

We recommend that you always compile with the latest available Target Framework version. Doing so provides you with helpful warning messages for any deprecated APIs that might be called by your code. Using the latest Target Framework version is especially important when you use the latest support library releases – each library expects your app to be compiled at that support library's minimum API level or greater.

What API calls you make, determinate how low you can go on the "Minimum android version", but it still compiles at eg 9.0.

I have some knowledge about this, but not at all an expert 👍

<AndroidTlsProvider>
</AndroidTlsProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
7 changes: 4 additions & 3 deletions Sample/Droid/DownloadExample.Droid.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -8,15 +8,16 @@
<OutputType>Library</OutputType>
<RootNamespace>DownloadExample.Droid</RootNamespace>
<AssemblyName>DownloadExample.Droid</AssemblyName>
<TargetFrameworkVersion>v7.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<AndroidTlsProvider></AndroidTlsProvider>
<AndroidTlsProvider>
</AndroidTlsProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
8 changes: 5 additions & 3 deletions Sample/Droid/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.example.download_example">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="25" />
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="28" />
<!--
You have to add this permission when setting `PathNameForDownloadedFile`.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-->
<application android:label="Download Example"></application>

<!-- usesCleartextTraffic must be enabled for Android 9 and downloads using http -->
<application android:label="Download Example" android:usesCleartextTraffic="true"></application>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only needed for Android 9 when trying to download content via HTTP, or does it also apply for older Versions of Android - or other protocols?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below Android 9 the defaults to android:usesCleartextTraffic="true".
Android 9 is the first project that sets android:usesCleartextTraffic="false" as default.
A downloadmanager that can't handle http downloads isn't very handy in my eye. But using http is considered as a safety risk.

</manifest>
14 changes: 10 additions & 4 deletions Sample/iOS/DownloadExample.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<DefineConstants></DefineConstants>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
Expand All @@ -50,7 +51,8 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<Optimize>true</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<DefineConstants></DefineConstants>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
Expand Down Expand Up @@ -91,8 +93,12 @@
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Assets.xcassets\AppIcons.appiconset\Contents.json" />
<ImageAsset Include="Assets.xcassets\Contents.json" />
<ImageAsset Include="Assets.xcassets\AppIcons.appiconset\Contents.json">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\Contents.json">
<Visible>false</Visible>
</ImageAsset>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
Expand Down