From 60f1bddda04ec5fa22778abf176171a547dde949 Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Thu, 25 Jan 2018 11:06:32 +0100 Subject: inapp billing --- Penguloon/AdManager.cs | 6 +++ Penguloon/MainApplication.cs | 63 ++++++++++++++++++++++++++++++++ Penguloon/Penguloon.csproj | 14 +++++++ Penguloon/Properties/AndroidManifest.xml | 3 +- Penguloon/app.config | 11 ++++++ Penguloon/packages.config | 2 + 6 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 Penguloon/MainApplication.cs create mode 100644 Penguloon/app.config (limited to 'Penguloon') diff --git a/Penguloon/AdManager.cs b/Penguloon/AdManager.cs index 65f464c..31135a5 100644 --- a/Penguloon/AdManager.cs +++ b/Penguloon/AdManager.cs @@ -24,8 +24,12 @@ namespace Penguloon public static InterstitialAd GameOverAd { get; set; } public static bool GameOverAdLoaded { get; set; } = false; + public static bool Enabled { get; set; } = false; + public static void Load(Main main) { + if (!Enabled) return; + LoadGameOverAd(main); } @@ -42,6 +46,8 @@ namespace Penguloon public static void ShowGameOverAd() { + if (!Enabled) return; + if (GameOverAdLoaded) GameOverAd.Show(); diff --git a/Penguloon/MainApplication.cs b/Penguloon/MainApplication.cs new file mode 100644 index 0000000..767d6f3 --- /dev/null +++ b/Penguloon/MainApplication.cs @@ -0,0 +1,63 @@ +using System; + +using Android.App; +using Android.OS; +using Android.Runtime; +using Plugin.CurrentActivity; + +namespace Penguloon +{ + //You can specify additional application information in this attribute + [Application] + public class MainApplication : Application, Application.IActivityLifecycleCallbacks + { + public MainApplication(IntPtr handle, JniHandleOwnership transer) + :base(handle, transer) + { + } + + public override void OnCreate() + { + base.OnCreate(); + RegisterActivityLifecycleCallbacks(this); + //A great place to initialize Xamarin.Insights and Dependency Services! + } + + public override void OnTerminate() + { + base.OnTerminate(); + UnregisterActivityLifecycleCallbacks(this); + } + + public void OnActivityCreated(Activity activity, Bundle savedInstanceState) + { + CrossCurrentActivity.Current.Activity = activity; + } + + public void OnActivityDestroyed(Activity activity) + { + } + + public void OnActivityPaused(Activity activity) + { + } + + public void OnActivityResumed(Activity activity) + { + CrossCurrentActivity.Current.Activity = activity; + } + + public void OnActivitySaveInstanceState(Activity activity, Bundle outState) + { + } + + public void OnActivityStarted(Activity activity) + { + CrossCurrentActivity.Current.Activity = activity; + } + + public void OnActivityStopped(Activity activity) + { + } + } +} \ No newline at end of file diff --git a/Penguloon/Penguloon.csproj b/Penguloon/Penguloon.csproj index 70adb27..837942b 100644 --- a/Penguloon/Penguloon.csproj +++ b/Penguloon/Penguloon.csproj @@ -62,6 +62,18 @@ ..\packages\Newtonsoft.Json.10.0.2\lib\netstandard1.3\Newtonsoft.Json.dll + + ..\packages\Plugin.CurrentActivity.1.0.1\lib\MonoAndroid10\Plugin.CurrentActivity.dll + + + ..\packages\Plugin.InAppBilling.1.2.4\lib\MonoAndroid10\Plugin.InAppBilling.dll + + + ..\packages\Plugin.InAppBilling.1.2.4\lib\MonoAndroid10\Plugin.InAppBilling.Abstractions.dll + + + ..\packages\Plugin.InAppBilling.1.2.4\lib\MonoAndroid10\Plugin.InAppBilling.VendingLibrary.dll + @@ -117,6 +129,7 @@ + @@ -150,6 +163,7 @@ + diff --git a/Penguloon/Properties/AndroidManifest.xml b/Penguloon/Properties/AndroidManifest.xml index 370e54c..04d8e47 100644 --- a/Penguloon/Properties/AndroidManifest.xml +++ b/Penguloon/Properties/AndroidManifest.xml @@ -1,10 +1,11 @@  - + + diff --git a/Penguloon/app.config b/Penguloon/app.config new file mode 100644 index 0000000..dde2c3c --- /dev/null +++ b/Penguloon/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Penguloon/packages.config b/Penguloon/packages.config index c1ab5d1..239ab89 100644 --- a/Penguloon/packages.config +++ b/Penguloon/packages.config @@ -5,6 +5,8 @@ + + -- cgit v1.2.3-70-g09d2