Skip to content

Commit

Permalink
.NET 8ify
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed May 24, 2024
1 parent a2dcb66 commit caac0ea
Show file tree
Hide file tree
Showing 125 changed files with 252 additions and 32,734 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*.userprefs

# Build results
.idea/
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
Expand Down
1 change: 1 addition & 0 deletions src/.idea/.idea.InAppBilling/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/.idea/.idea.InAppBilling/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/.idea/.idea.InAppBilling/.idea/projectSettingsUpdater.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/.idea/.idea.InAppBilling/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

435 changes: 0 additions & 435 deletions src/InAppBilling.sln

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/InAppBillingTests/InAppBillingMauiTest/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
x:Class="InAppBillingMauiTest.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:InAppBillingMauiTest"
xmlns:local="clr-namespace:InAppBillingTests"
Shell.FlyoutBehavior="Disabled">

<ShellContent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>InAppBillingMauiTest</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>InAppBillingMauiTest</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.inappbillingmauitest</ApplicationId>
<ApplicationId Condition="$(TargetFramework.Contains('-windows'))">8C7E9190-68F2-4D7E-BF0E-C1E8A260B4D5</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.Contains('-android')) ">
<PackageReference Include="Xamarin.Android.Google.BillingClient" Version="4.0.0" />
<PropertyGroup>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>InAppBillingMauiTest</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>InAppBillingMauiTest</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.inappbillingmauitest</ApplicationId>
<ApplicationId Condition="$(TargetFramework.Contains('-windows'))">8C7E9190-68F2-4D7E-BF0E-C1E8A260B4D5</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net8.0-ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net8.0-maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net8.0-android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4"/>

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128"/>

<!-- Images -->
<MauiImage Include="Resources\Images\*"/>
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208"/>

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*"/>

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Plugin.InAppBilling\Plugin.InAppBilling.csproj"/>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Plugin.InAppBilling\Plugin.InAppBilling.csproj" />
</ItemGroup>

</Project>
58 changes: 18 additions & 40 deletions src/InAppBillingTests/InAppBillingMauiTest/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="InAppBillingMauiTest.MainPage">
xmlns:iap="clr-namespace:Plugin.InAppBilling;assembly=Plugin.InAppBilling"
x:Class="InAppBillingTests.MainPage">

<ScrollView>
<VerticalStackLayout Spacing="25" Padding="30">

<Label
Text="Hello, World!"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />

<Label
Text="Welcome to .NET Multi-platform App UI"
SemanticProperties.HeadingLevel="Level1"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />

<Label
Text="Current count: 0"
FontSize="18"
FontAttributes="Bold"
x:Name="CounterLabel"
HorizontalOptions="Center" />

<Button
Text="Click me"
FontAttributes="Bold"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Center" />

<Image
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
WidthRequest="250"
HeightRequest="310"
HorizontalOptions="Center" />

</VerticalStackLayout>
</ScrollView>
<VerticalStackLayout>
<Button Text="Buy Consumable" x:Name="ButtonConsumable" Clicked="ButtonConsumable_Clicked"/>
<Button Text="Buy Non-Consumable" x:Name="ButtonNonConsumable" Clicked="ButtonNonConsumable_Clicked"/>
<Button Text="Buy Sub" x:Name="ButtonSub" Clicked="ButtonSub_Clicked"/>
<Button Text="Buy Renewing Sub" x:Name="ButtonRenewingSub" Clicked="ButtonRenewingSub_Clicked"/>
<Button Text="Get Subscrition Purchases" x:Name="ButtonRestore" Clicked="ButtonRestore_Clicked"/>
<Button Text="Get Product Info" x:Name="ButtonProductInfo" Clicked="ButtonProductInfo_Clicked"/>
<ListView ItemsSource="{Binding Items}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="iap:InAppBillingProduct">
<TextCell Text="{Binding ProductId}"
Detail="{Binding Name}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout>
</ContentPage>
144 changes: 132 additions & 12 deletions src/InAppBillingTests/InAppBillingMauiTest/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,140 @@
namespace InAppBillingMauiTest
using Plugin.InAppBilling;
using System.Collections.ObjectModel;

namespace InAppBillingTests
{
public partial class MainPage : ContentPage
{
int count = 0;
{
public ObservableCollection<InAppBillingProduct> Items { get; } = new();
public MainPage()
{
InitializeComponent();
}

public MainPage()
{
InitializeComponent();
private void ButtonConsumable_Clicked(object sender, EventArgs e)
{

}

private async void ButtonNonConsumable_Clicked(object sender, EventArgs e)
{
var id = "iaptest";
try
{
await CrossInAppBilling.Current.ConnectAsync();
var purchase = await CrossInAppBilling.Current.PurchaseAsync(id, ItemType.InAppPurchase);

if (purchase == null)
{
await DisplayAlert(string.Empty, "Did not purchase", "OK");
}
else
{
#if ANDROID
if (purchase.IsAcknowledged == false)
await CrossInAppBilling.Current.FinalizePurchaseAsync([purchase.PurchaseToken]);
#endif
await DisplayAlert(string.Empty, "We did it!", "OK");
}
}
catch (Exception ex)
{
await DisplayAlert(string.Empty, "Did not purchase: " + ex.Message, "OK");
Console.WriteLine(ex);
}
finally
{

await CrossInAppBilling.Current.DisconnectAsync();
}
}

private async void ButtonSub_Clicked(object sender, EventArgs e)
{
var id = "renewsub";
try
{
await CrossInAppBilling.Current.ConnectAsync();
var purchase = await CrossInAppBilling.Current.PurchaseAsync(id, ItemType.Subscription);

if(purchase == null)
{
await DisplayAlert(string.Empty, "Did not purchase", "OK");
}
else
{
#if ANDROID
if (purchase.IsAcknowledged == false)
await CrossInAppBilling.Current.FinalizePurchaseAsync([purchase.PurchaseToken]);
#endif
await DisplayAlert(string.Empty, "We did it!", "OK");
}
}
catch (Exception ex)
{
await DisplayAlert(string.Empty, "Did not purchase: " + ex.Message, "OK");
Console.WriteLine(ex);
}
finally
{

await CrossInAppBilling.Current.DisconnectAsync();
}
}

private void OnCounterClicked(object sender, EventArgs e)
private async void ButtonRenewingSub_Clicked(object sender, EventArgs e)
{

}

private async void ButtonProductInfo_Clicked(object sender, EventArgs e)
{
count++;
CounterLabel.Text = $"Current count: {count}";
try
{
await CrossInAppBilling.Current.ConnectAsync();
var items = await CrossInAppBilling.Current.GetProductInfoAsync(ItemType.InAppPurchase, ["iaptest"]);
Items.Clear();
foreach (var item in items)
Items.Add(item);
}
catch (Exception ex)
{
await DisplayAlert(string.Empty, "Did not purchase: " + ex.Message, "OK");
Console.WriteLine(ex);
}
finally
{

await CrossInAppBilling.Current.DisconnectAsync();
}
}

private async void ButtonRestore_Clicked(object sender, EventArgs e)
{
try
{
await CrossInAppBilling.Current.ConnectAsync();
var purchases = await CrossInAppBilling.Current.GetPurchasesAsync(ItemType.Subscription);

if (purchases == null)
{
await DisplayAlert(string.Empty, "Did not purchase", "OK");
}
else
{
await DisplayAlert(string.Empty, "We did it!", "OK");
}
}
catch (Exception ex)
{

Console.WriteLine(ex);
}
finally
{

SemanticScreenReader.Announce(CounterLabel.Text);
await CrossInAppBilling.Current.DisconnectAsync();
}
}
}
}
}
}

This file was deleted.

Loading

0 comments on commit caac0ea

Please sign in to comment.