Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
-Renamed File/Folder/FileSystemContainerBase to File/Folder/FileSyste…
Browse files Browse the repository at this point in the history
…mContainer. This is because the user is interacting with the classes directly as a Container, so the naming looks better.

-Added CreationCollisonOption Handling into the FolderContainer Abstraction, this gets overriden by UWPs Implementation for StorageFolders. This was reworked to ensure all Folder Implementations use the same Default Collision Option of FailIfExists.

-In FolderContainer, added FileExistsAsync and FolderExistsAsync, made GetItemsAsync Virtual to be overriden if required.

-Removed Delete Void from FileSystemContainer, added CanWrite method check to see if the file/folder can be written to.

-Added FormatMarkers Support to PromptUser methods, this is a custom formatting technique of my own design, that allows spans of formatted text. Currently this is limited to toggling Bold with ^B^. This is currently supported by UWP and Android, and Removed from Console as it is unsupported.

-Merged Android Shared Projects back into one. There is now a Toggle Boolean to use any Android AppComapt UI Classes over the default, called AndroidAppServices.UseAppCompatUI.

-Created AlertDialogBuilder class Abstractions to handle setting PromptUser Dialog data in a uniform manner between the Default and AppCompat AlertDialogBuilder.

-You can now fetch the CurrentActivity without providing a UIBinding.

-Added AndroidDocumentsProviderFile/Folder Containers, these allow you to interact with files/folders from Android's Picker, however, Opening files with the Default App fails as Uris need to be reshared.

-Added UpdateCurrentActivity back to OnCreate for PlatformBindingActivity, as it is required for UI handling during the OnCreate period of an Activity, such as Prompting the User with a Dialog.

-Added more File/Folder Test Procedures.
  • Loading branch information
WilliamABradley committed Nov 14, 2017
1 parent eb1b755 commit c1cb381
Show file tree
Hide file tree
Showing 57 changed files with 6,260 additions and 505 deletions.
31 changes: 0 additions & 31 deletions Android-AppCompatV7/PlatformBindings-Android-AppCompatV7.csproj

This file was deleted.

31 changes: 0 additions & 31 deletions Android-Shared/PlatformBindings-Android-Shared.projitems

This file was deleted.

13 changes: 0 additions & 13 deletions Android-Shared/PlatformBindings-Android-Shared.shproj

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ public void UpdateCurrentActivity()
}

var uibinding = AppServices.UI.DefaultUIBinding as AndroidUIBindingInfo;
uibinding.Activity =
#if APPCOMPAT
(Android.Support.V7.App.AppCompatActivity)
#endif
Activity;
uibinding.Activity = Activity;
if (AndroidAppServices.UseAppCompatUI) uibinding.CompatActivity = (Android.Support.V7.App.AppCompatActivity)Activity;
}

public Task<ActivityResult> StartActivityForResultAsync(Type ActivityType)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;

namespace PlatformBindings.Activities
{
#if APPCOMPAT
public class PlatformBindingCompatActivity : Android.Support.V7.App.AppCompatActivity
{
public PlatformBindingCompatActivity()
{
#else
public class PlatformBindingActivity : Activity
{
public PlatformBindingActivity()
{
#endif

Handler = ActivityHandler.GetActivityHandler(this);
}

protected override void OnCreate(Bundle savedInstanceState)
{
Handler.UpdateCurrentActivity();
base.OnCreate(savedInstanceState);
}

protected override void OnResume()
{
Handler.UpdateCurrentActivity();
Expand Down
45 changes: 45 additions & 0 deletions Android/Activities/PlatformBindingCompatActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;

namespace PlatformBindings.Activities
{
public class PlatformBindingCompatActivity : Android.Support.V7.App.AppCompatActivity
{
public PlatformBindingCompatActivity()
{
Handler = ActivityHandler.GetActivityHandler(this);
}

protected override void OnCreate(Bundle savedInstanceState)
{
Handler.UpdateCurrentActivity();
base.OnCreate(savedInstanceState);
}

protected override void OnResume()
{
Handler.UpdateCurrentActivity();
base.OnResume();
}

protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
Handler.UpdateCurrentActivity();
Handler.OnActivityResult(requestCode, resultCode, data);
base.OnActivityResult(requestCode, resultCode, data);
}

public override void OnCreateContextMenu(IContextMenu menu, View v, IContextMenuContextMenuInfo menuInfo)
{
if (!Handler.OnCreateContextMenu(menu, v, menuInfo))
{
base.OnCreateContextMenu(menu, v, menuInfo);
}
}

public ActivityHandler Handler { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace PlatformBindings
{
public class AndroidAppServices : AppServices
{
public AndroidAppServices(bool HasUI, bool UseAppCompatUI) : this(HasUI)
{
AndroidAppServices.UseAppCompatUI = UseAppCompatUI;
}

public AndroidAppServices(bool HasUI) : base(HasUI)
{
if (HasUI) UI = new AndroidUIBindings();
Expand All @@ -17,5 +22,7 @@ public override Version GetAppVersion()
var info = Application.Context.PackageManager.GetPackageInfo(Application.Context.PackageName, Android.Content.PM.PackageInfoFlags.MetaData);
return new Version(info.VersionName);
}

public static bool UseAppCompatUI { get; private set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace PlatformBindings.Common
{
public static class AndroidHelpers
{
public static Activity GetCurrentActivity()
{
return GetCurrentActivity(null);
}

public static Activity GetCurrentActivity(this IUIBindingInfo UIBinding)
{
var uibinding = (UIBinding ?? AppServices.UI.DefaultUIBinding) as AndroidUIBindingInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using Android.App;
using Android.App;
using Android.Content;

namespace PlatformBindings.Models
Expand Down
55 changes: 55 additions & 0 deletions Android/Models/DialogHandling/AlertDialogBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using Java.Lang;
using Android.App;
using Android.Content;
using PlatformBindings.Enums;
using Android.Views;
using System.Threading.Tasks;

namespace PlatformBindings.Models.DialogHandling
{
public class AlertDialogBuilder : AlertDialogBuilderBase
{
public AlertDialogBuilder(Context Context) : base(Context)
{
Builder = new AlertDialog.Builder(Context);
}

public override void SetMessage(ICharSequence text)
{
Builder.SetMessage(text);
}

public override void SetPrimaryButton(ICharSequence text)
{
Builder.SetNegativeButton(text, new EventHandler<DialogClickEventArgs>((s, e) => Waiter.TrySetResult(DialogResult.Primary)));
}

public override void SetSecondaryButton(ICharSequence text)
{
Builder.SetPositiveButton(text, new EventHandler<DialogClickEventArgs>((s, e) => Waiter.TrySetResult(DialogResult.Secondary)));
}

public override void SetTitle(ICharSequence text)
{
Builder.SetTitle(text);
}

public override void SetView(View view)
{
Builder.SetView(view);
}

public override void SetView(int LayoutResId)
{
Builder.SetView(LayoutResId);
}

public override void Show()
{
Builder.Show();
}

private AlertDialog.Builder Builder { get; }
}
}
65 changes: 65 additions & 0 deletions Android/Models/DialogHandling/AlertDialogBuilderBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using Android.Content;
using Android.Views;
using Java.Lang;
using PlatformBindings.Enums;
using System.Threading.Tasks;

namespace PlatformBindings.Models.DialogHandling
{
public abstract class AlertDialogBuilderBase
{
public static AlertDialogBuilderBase Pick(Context Context)
{
if (AndroidAppServices.UseAppCompatUI) return new CompatAlertDialogBuilder(Context);
else return new AlertDialogBuilder(Context);
}

public AlertDialogBuilderBase(Context Context)
{
this.Context = Context;
}

public void SetTitle(string text)
{
SetTitle(new String(text));
}

public abstract void SetTitle(ICharSequence text);

public void SetMessage(string text)
{
SetMessage(new String(text));
}

public abstract void SetMessage(ICharSequence text);

public void SetPrimaryButton(string text)
{
SetPrimaryButton(new String(text));
}

public abstract void SetPrimaryButton(ICharSequence text);

public void SetSecondaryButton(string text)
{
SetSecondaryButton(new String(text));
}

public abstract void SetSecondaryButton(ICharSequence text);

public abstract void SetView(View view);

public abstract void SetView(int LayoutResId);

public abstract void Show();

public async Task<DialogResult> ShowAsync()
{
Show();
return await Waiter.Task;
}

public Context Context { get; }
protected TaskCompletionSource<DialogResult> Waiter = new TaskCompletionSource<DialogResult>();
}
}
53 changes: 53 additions & 0 deletions Android/Models/DialogHandling/CompatAlertDialogBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using Java.Lang;
using Android.Content;
using PlatformBindings.Enums;
using Android.Views;

namespace PlatformBindings.Models.DialogHandling
{
public class CompatAlertDialogBuilder : AlertDialogBuilderBase
{
public CompatAlertDialogBuilder(Context Context) : base(Context)
{
Builder = new Android.Support.V7.App.AlertDialog.Builder(Context);
}

public override void SetMessage(ICharSequence text)
{
Builder.SetMessage(text);
}

public override void SetPrimaryButton(ICharSequence text)
{
Builder.SetPositiveButton(text, new EventHandler<DialogClickEventArgs>((s, e) => Waiter.TrySetResult(DialogResult.Primary)));
}

public override void SetSecondaryButton(ICharSequence text)
{
Builder.SetNegativeButton(text, new EventHandler<DialogClickEventArgs>((s, e) => Waiter.TrySetResult(DialogResult.Secondary)));
}

public override void SetTitle(ICharSequence text)
{
Builder.SetTitle(text);
}

public override void SetView(View view)
{
Builder.SetView(view);
}

public override void SetView(int LayoutResId)
{
Builder.SetView(LayoutResId);
}

public override void Show()
{
Builder.Show();
}

private Android.Support.V7.App.AlertDialog.Builder Builder { get; }
}
}
Loading

0 comments on commit c1cb381

Please sign in to comment.