-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use Xamarin.Google.Android.Play.App.Update.Ktx(flexible updates…
… not supported)
- Loading branch information
Showing
8 changed files
with
116 additions
and
103 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
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
121 changes: 60 additions & 61 deletions
121
src/libs/Maui.Android.InAppUpdates/Platforms/Android/InstallStateUpdatedListener.cs
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 |
---|---|---|
@@ -1,61 +1,60 @@ | ||
using Xamarin.Google.Android.Play.Core.Install; | ||
using Xamarin.Google.Android.Play.Core.Install.Model; | ||
using Object = Java.Lang.Object; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Maui.Android.InAppUpdates.Internal; | ||
|
||
/// <summary> | ||
/// Listener to track request state updates. | ||
/// </summary> | ||
public class InstallStateUpdatedListener | ||
: Object, IInstallStateUpdatedListener | ||
{ | ||
/// <summary> | ||
/// This method will be triggered when the app update status is changed. | ||
/// </summary> | ||
/// <param name="state"></param> | ||
/// <exception cref="ArgumentNullException"></exception> | ||
public void OnStateUpdate(InstallState state) | ||
{ | ||
state = state ?? throw new ArgumentNullException(nameof(state)); | ||
|
||
try | ||
{ | ||
var installStatus = state.InstallStatus(); | ||
switch (installStatus) | ||
{ | ||
case InstallStatus.Unknown: | ||
case InstallStatus.Pending: | ||
case InstallStatus.Installing: | ||
case InstallStatus.Installed: | ||
case InstallStatus.Canceled: | ||
break; | ||
|
||
case InstallStatus.Downloading | ||
when Handler.Options.ShowDownload: | ||
{ | ||
var bytesDownloaded = state.BytesDownloaded(); | ||
var totalBytesToDownload = state.TotalBytesToDownload() + 1; | ||
var percents = Math.Round( | ||
100.0 * bytesDownloaded / totalBytesToDownload); | ||
|
||
Handler.Options.DownloadingAction(percents); | ||
break; | ||
} | ||
|
||
case InstallStatus.Downloaded: | ||
Handler.Options.CompleteUpdateAction(); | ||
break; | ||
|
||
case InstallStatus.Failed: | ||
Handler.Options.DownloadFailedAction(); | ||
break; | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Handler.Options.DebugAction($"Error occurred during in app update status change: {e}"); | ||
} | ||
} | ||
} | ||
// using Xamarin.Google.Android.Play.Core.AppUpdate.Install; | ||
// using Xamarin.Google.Android.Play.Core.AppUpdate.Install.Model; | ||
// | ||
// // ReSharper disable once CheckNamespace | ||
// namespace Maui.Android.InAppUpdates.Internal; | ||
// | ||
// /// <summary> | ||
// /// Listener to track request state updates. | ||
// /// </summary> | ||
// public class InstallStateUpdatedListener | ||
// : Java.Lang.Object, IInstallStateUpdatedListener | ||
// { | ||
// /// <summary> | ||
// /// This method will be triggered when the app update status is changed. | ||
// /// </summary> | ||
// /// <param name="p0"></param> | ||
// /// <exception cref="ArgumentNullException"></exception> | ||
// public void OnStateUpdate(Java.Lang.Object p0) | ||
// { | ||
// var state = p0 as InstallState ?? throw new ArgumentNullException(nameof(p0)); | ||
// | ||
// try | ||
// { | ||
// var installStatus = state.InstallStatus(); | ||
// switch (installStatus) | ||
// { | ||
// case InstallStatus.Unknown: | ||
// case InstallStatus.Pending: | ||
// case InstallStatus.Installing: | ||
// case InstallStatus.Installed: | ||
// case InstallStatus.Canceled: | ||
// break; | ||
// | ||
// case InstallStatus.Downloading | ||
// when Handler.Options.ShowDownload: | ||
// { | ||
// var bytesDownloaded = state.BytesDownloaded(); | ||
// var totalBytesToDownload = state.TotalBytesToDownload() + 1; | ||
// var percents = Math.Round( | ||
// 100.0 * bytesDownloaded / totalBytesToDownload); | ||
// | ||
// Handler.Options.DownloadingAction(percents); | ||
// break; | ||
// } | ||
// | ||
// case InstallStatus.Downloaded: | ||
// Handler.Options.CompleteUpdateAction(); | ||
// break; | ||
// | ||
// case InstallStatus.Failed: | ||
// Handler.Options.DownloadFailedAction(); | ||
// break; | ||
// } | ||
// } | ||
// catch (Exception e) | ||
// { | ||
// Handler.Options.DebugAction($"Error occurred during in app update status change: {e}"); | ||
// } | ||
// } | ||
// } |
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