-
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.
- Loading branch information
Showing
10 changed files
with
70 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Snackbar/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
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
63 changes: 32 additions & 31 deletions
63
src/libs/Maui.Android.InAppUpdates/Platforms/Android/DefaultUserInterface.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,46 +1,47 @@ | ||
using Android.App; | ||
using Android.Content; | ||
using Android.Views; | ||
using Android.Widget; | ||
using Xamarin.Google.Android.Play.Core.AppUpdate; | ||
using Google.Android.Material.Snackbar; | ||
|
||
namespace Maui.Android.InAppUpdates.Internal; | ||
|
||
public static class DefaultUserInterface | ||
{ | ||
/// <summary> | ||
/// This method will show the alert dialog to complete the update. | ||
/// Displays a short duration toast message at the center of the screen. | ||
/// </summary> | ||
/// <param name="context"></param> | ||
/// <param name="appUpdateManager"></param> | ||
public static void ShowAlertToCompleteUpdate( | ||
Context context, | ||
IAppUpdateManager appUpdateManager, | ||
string title, | ||
string message, | ||
string positiveButton) | ||
/// <param name="text">The text to be displayed in the toast message.</param> | ||
public static void ShowShortToast( | ||
string text) | ||
{ | ||
if (new AlertDialog.Builder(context).Create() is not {} alert) | ||
Toast.MakeText( | ||
context: Platform.AppContext, | ||
text: text, | ||
duration: ToastLength.Short)?.Show(); | ||
} | ||
|
||
/// <summary> | ||
/// Displays a snackbar with an action to complete the app update process. | ||
/// </summary> | ||
/// <param name="text">The text to display on the snackbar.</param> | ||
/// <param name="actionText">The text for the action button.</param> | ||
/// <param name="clickHandler">The handler for the action button.</param> | ||
public static void ShowSnackbar( | ||
string text, | ||
string actionText, | ||
Action<global::Android.Views.View> clickHandler) | ||
{ | ||
if (Platform.CurrentActivity?.Window?.DecorView is not {} view || | ||
Snackbar.Make( | ||
text: text, | ||
duration: BaseTransientBottomBar.LengthIndefinite, | ||
view: view) is not {} snackbar) | ||
{ | ||
return; | ||
} | ||
|
||
alert.SetTitle(title); | ||
alert.SetMessage(message); | ||
alert.SetButton((int) DialogButtonType.Positive, positiveButton, (_, _) => | ||
{ | ||
appUpdateManager.CompleteUpdate(); | ||
// You can start your activityonresult method when update is not available when using immediate update when testing with fakeappupdate manager | ||
//activity.StartActivityForResult(intent, 400); | ||
}); | ||
alert.SetCancelable(false); | ||
alert.Show(); | ||
} | ||
|
||
public static void ShowShortToast(Context context, string text) | ||
{ | ||
Toast.MakeText( | ||
context: context, | ||
text: text, | ||
duration: ToastLength.Short)?.Show(); | ||
snackbar.SetAction( | ||
text: actionText, | ||
clickHandler: clickHandler); | ||
snackbar.Show(); | ||
} | ||
} |
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