Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add extension to Asset Delivery (#842)
It adds the `AssetPackStateUpdateListenerWrapper` to the `Xamarini.Google.Android.Play.Asset.Delivery` nuget package to help users deal with ondemand asset packs. This class is also n the Xamarin.Google.Android.Play.Core package, but that package has been depricated and appears to have issues on API 34. Remove the old `AssetPackStateUpdateListenerWrapper` from `Xamarini.Google.Android.Play.Core` as it will conflict with the one that will be in `Xamarini.Google.Android.Play.Asset.Delivery`. Do the same for the `SplitInstallStateUpdateListenerWrapper` this will now be in `Xamarini.Google.Android.Play.Feature.Delivery`. Add a sample app called `BuildAllPlayDotNet` which will use the Asset Delivery API and the wrapper class to make sure it is compiled into the nuget package.
- Loading branch information
1 parent
3ba6fbc
commit 204f71c
Showing
107 changed files
with
1,245 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.28606.126 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildAllPlayDotNet", "BuildAllPlayDotNet\BuildAllPlayDotNet.csproj", "{7CA41D33-5A33-4968-AEBD-9A76B7E83BB7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{7CA41D33-5A33-4968-AEBD-9A76B7E83BB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{7CA41D33-5A33-4968-AEBD-9A76B7E83BB7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{7CA41D33-5A33-4968-AEBD-9A76B7E83BB7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU | ||
{7CA41D33-5A33-4968-AEBD-9A76B7E83BB7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{7CA41D33-5A33-4968-AEBD-9A76B7E83BB7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{7CA41D33-5A33-4968-AEBD-9A76B7E83BB7}.Release|Any CPU.Deploy.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {47AA0B75-DCFB-4D55-AFC5-DB072FDDCCB1} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> | ||
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" > | ||
</application> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FastFollow Asset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Install Time Asset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
OnDemand Asset |
42 changes: 42 additions & 0 deletions
42
samples/dotnet/BuildAllPlayDotNet/BuildAllPlayDotNet.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>$(_DefaultDotNetSampleTargetFrameworks)</TargetFrameworks> | ||
<AndroidPackageFormat>aab</AndroidPackageFormat> | ||
<!-- Some packages specify a minimum of 28 (eg: Xamarin.AndroidX.HeifWriter) --> | ||
|
||
<SupportedOSPlatformVersion>29</SupportedOSPlatformVersion> | ||
<OutputType>Exe</OutputType> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<ApplicationId>com.companyname.BuildAllDotNet</ApplicationId> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<AndroidBundleToolExtraArgs Condition=" '$(Configuration)' == 'Debug' ">--local-testing</AndroidBundleToolExtraArgs> | ||
|
||
<!-- Override property from 'Directory.Build.props' --> | ||
<!-- | ||
<AndroidGenerateResourceDesigner>true</AndroidGenerateResourceDesigner> | ||
--> | ||
|
||
<!-- Prevent linking, since that would remove ~everything --> | ||
<!-- | ||
<PublishTrimmed>False</PublishTrimmed> | ||
<RunAOTCompilation>False</RunAOTCompilation> | ||
--> | ||
|
||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<AndroidAsset Update="Assets/InstallTimeAsset.txt" AssetPack="installtimepack" DeliveryType="InstallTime" /> | ||
<AndroidAsset Update="Assets/FastFollowAsset.txt" AssetPack="fastfollowpack" DeliveryType="FastFollow" /> | ||
<AndroidAsset Update="Assets/OnDemandAsset.txt" AssetPack="ondemandpack" DeliveryType="OnDemand" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Xamarin.Google.Android.Play.Asset.Delivery" Version="2.1.0.5" /> | ||
<!-- Remove the old Conflicting Package otherwise this causes build errors. --> | ||
<PackageReference Remove="Xamarin.Google.Android.Play.Core" Version="2.1.0.5" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!-- This is empty to prevent picking up any parent Directory.Build.targets. --> | ||
<Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Android.App; | ||
using Android.Content.PM; | ||
using Android.Runtime; | ||
using Android.OS; | ||
|
||
using Xamarin.Google.Android.Play.Core.AssetPacks; | ||
using Xamarin.Google.Android.Play.Core.AssetPacks.Model; | ||
using static Xamarin.Google.Android.Play.Core.AssetPacks.AssetPackStateUpdateListenerWrapper; | ||
|
||
namespace BuildAllPlayDotNet; | ||
|
||
[Activity(Label = "@string/app_name", MainLauncher = true)] | ||
public class MainActivity : Activity | ||
{ | ||
IAssetPackManager? assetPackManager; | ||
AssetPackStateUpdateListenerWrapper? listener; | ||
|
||
protected override void OnCreate(Bundle? savedInstanceState) | ||
{ | ||
base.OnCreate(savedInstanceState); | ||
|
||
// Set our view from the "main" layout resource | ||
SetContentView(Resource.Layout.activity_main); | ||
|
||
assetPackManager = AssetPackManagerFactory.GetInstance (this); | ||
// Create our Wrapper and set up the event handler. | ||
listener = new AssetPackStateUpdateListenerWrapper(); | ||
listener.StateUpdate += Listener_StateUpdate; | ||
|
||
var location = assetPackManager.GetPackLocation ("installtimepack"); | ||
assetPackManager.Fetch (new string[] {"fastfollowpack"}); | ||
assetPackManager.Fetch (new string[] {"ondemandpack"}); | ||
} | ||
|
||
void Listener_StateUpdate(object? sender, AssetPackStateEventArgs e) | ||
{ | ||
var status = e.State.Status(); | ||
Android.Util.Log.Info ("Listener_StateUpdate", status.ToString ()); | ||
} | ||
|
||
protected override void OnResume() | ||
{ | ||
// regsiter our Listener Wrapper with the IAssetPackManager so we get feedback. | ||
assetPackManager?.RegisterListener(listener?.Listener); | ||
base.OnResume(); | ||
} | ||
|
||
protected override void OnPause() | ||
{ | ||
assetPackManager?.UnregisterListener(listener?.Listener); | ||
base.OnPause(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
samples/dotnet/BuildAllPlayDotNet/Resources/AboutResources.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Images, layout descriptions, binary blobs and string dictionaries can be included | ||
in your application as resource files. Various Android APIs are designed to | ||
operate on the resource IDs instead of dealing with images, strings or binary blobs | ||
directly. | ||
|
||
For example, a sample Android app that contains a user interface layout (main.xml), | ||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) | ||
would keep its resources in the "Resources" directory of the application: | ||
|
||
Resources/ | ||
drawable/ | ||
icon.png | ||
|
||
layout/ | ||
main.xml | ||
|
||
values/ | ||
strings.xml | ||
|
||
In order to get the build system to recognize Android resources, set the build action to | ||
"AndroidResource". The native Android APIs do not operate directly with filenames, but | ||
instead operate on resource IDs. When you compile an Android application that uses resources, | ||
the build system will package the resources for distribution and generate a class called "Resource" | ||
(this is an Android convention) that contains the tokens for each one of the resources | ||
included. For example, for the above Resources layout, this is what the Resource class would expose: | ||
|
||
public class Resource { | ||
public class Drawable { | ||
public const int icon = 0x123; | ||
} | ||
|
||
public class Layout { | ||
public const int main = 0x456; | ||
} | ||
|
||
public class Strings { | ||
public const int first_string = 0xabc; | ||
public const int second_string = 0xbcd; | ||
} | ||
} | ||
|
||
You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or | ||
Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string | ||
to reference the first string in the dictionary file values/strings.xml. |
13 changes: 13 additions & 0 deletions
13
samples/dotnet/BuildAllPlayDotNet/Resources/layout/activity_main.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerInParent="true" | ||
android:text="@string/app_text" | ||
/> | ||
</RelativeLayout> |
5 changes: 5 additions & 0 deletions
5
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-anydpi-v26/ic_launcher.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@color/ic_launcher_background"/> | ||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/> | ||
</adaptive-icon> |
5 changes: 5 additions & 0 deletions
5
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-anydpi-v26/ic_launcher_round.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@color/ic_launcher_background"/> | ||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/> | ||
</adaptive-icon> |
Binary file added
BIN
+1.6 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.41 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-hdpi/ic_launcher_foreground.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.47 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-hdpi/ic_launcher_round.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.33 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+958 Bytes
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-mdpi/ic_launcher_foreground.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.36 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-mdpi/ic_launcher_round.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.25 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.01 KB
...les/dotnet/BuildAllPlayDotNet/Resources/mipmap-xhdpi/ic_launcher_foreground.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.74 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-xhdpi/ic_launcher_round.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.78 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-xxhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.32 KB
...es/dotnet/BuildAllPlayDotNet/Resources/mipmap-xxhdpi/ic_launcher_foreground.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.81 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-xxhdpi/ic_launcher_round.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.9 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-xxxhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.77 KB
...s/dotnet/BuildAllPlayDotNet/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.6 KB
samples/dotnet/BuildAllPlayDotNet/Resources/mipmap-xxxhdpi/ic_launcher_round.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
samples/dotnet/BuildAllPlayDotNet/Resources/values/ic_launcher_background.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="ic_launcher_background">#2C3E50</color> | ||
</resources> |
4 changes: 4 additions & 0 deletions
4
samples/dotnet/BuildAllPlayDotNet/Resources/values/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<resources> | ||
<string name="app_name">BuildAllDotNet</string> | ||
<string name="app_text">Hello, Android!</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
source/com.google.android.play/asset.delivery.extensions/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
6 changes: 6 additions & 0 deletions
6
source/com.google.android.play/asset.delivery.extensions/app/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/> | ||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | ||
<classpathentry kind="output" path="bin/default"/> | ||
</classpath> |
1 change: 1 addition & 0 deletions
1
source/com.google.android.play/asset.delivery.extensions/app/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Oops, something went wrong.