Skip to content

Commit

Permalink
Bump to latest (#71)
Browse files Browse the repository at this point in the history
- Window lifecycle (dotnet#1754)
- Move New Navigation Handler to Core and make it internal (dotnet#1800)
- Scrollview handler (dotnet#1669)
- ScrollView Resize + Window Handler Resize (dotnet#1676)
- Font AutoScalingEnabled (dotnet#1774)
- Rename Font Properties (dotnet#1755)
- Update layout system to ensure native measure/arrange are called for all controls, even from Page subclasses (dotnet#1819)
- IContainer as IList<IView> (dotnet#1724)
- Implement Layout padding for new StackLayouts and GridLayout (dotnet#1749)
- Delete all the TabIndex, TabStop, Focusable things! (dotnet#1777)
- Introduce SetSemanticFocus API via SemanticExtensions (dotnet#1829)
- Improve Window and AnimationManager (dotnet#1653)
- And so on
  • Loading branch information
rookiejava committed Aug 9, 2021
1 parent 98444dc commit ff48053
Show file tree
Hide file tree
Showing 31 changed files with 696 additions and 468 deletions.
34 changes: 34 additions & 0 deletions src/Compatibility/Core/src/AppHostBuilderExtensions.Tizen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Microsoft.Maui.Hosting;
using Microsoft.Maui.LifecycleEvents;
using Microsoft.Maui.Controls.Compatibility;

namespace Microsoft.Maui.Controls.Hosting
{
public static partial class AppHostBuilderExtensions
{
internal static IAppHostBuilder ConfigureCompatibilityLifecycleEvents(this IAppHostBuilder builder) =>
builder.ConfigureLifecycleEvents(events => events.AddTizen(OnConfigureLifeCycle));

static void OnConfigureLifeCycle(ITizenLifecycleBuilder tizen)
{
tizen.OnPreCreate((app) =>
{
// This is the initial Init to set up any system services registered by
// Forms.Init(). This happens before any UI has appeared.
// This creates a dummy MauiContext.
var services = MauiApplication.Current.Services;
MauiContext mauiContext = new MauiContext(services, CoreUIAppContext.GetInstance(MauiApplication.Current));
ActivationState state = new ActivationState(mauiContext);
Forms.Init(state, new InitializationOptions(MauiApplication.Current) { Flags = InitializationFlags.SkipRenderers, DisplayResolutionUnit = DisplayResolutionUnit.DP() });
})
.OnMauiContextCreated((mauiContext) =>
{
// This is the final Init that sets up the real context from the application.
var state = new ActivationState(mauiContext!);
Forms.Init(state);
});
}
}
}
3 changes: 3 additions & 0 deletions src/Compatibility/Core/src/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
using DefaultRenderer = Microsoft.Maui.Controls.Compatibility.Platform.iOS.Platform.DefaultRenderer;
#elif TIZEN
using Microsoft.Maui.Controls.Compatibility.Platform.Tizen;
using Microsoft.Maui.Graphics.Skia;
using BoxRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.BoxViewRenderer;
using CollectionViewRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.StructuredItemsViewRenderer;
using OpenGLViewRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.DefaultRenderer;
Expand Down Expand Up @@ -215,6 +216,8 @@ public void ConfigureServices(HostBuilderContext context, IServiceCollection ser
services.AddSingleton<IGraphicsService>(NativeGraphicsService.Instance);
#elif WINDOWS
services.AddSingleton<IGraphicsService>(W2DGraphicsService.Instance);
#elif TIZEN
services.AddSingleton<IGraphicsService>(SkiaGraphicsService.Instance);
#endif
}

Expand Down
11 changes: 1 addition & 10 deletions src/Compatibility/Core/src/Compatibility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
<ItemGroup>
<Compile Remove="GTK\**" />
<Compile Remove="MacOS\**" />
<Compile Remove="Tizen\**" />
<Compile Remove="WPF\**" />
<EmbeddedResource Remove="GTK\**" />
<EmbeddedResource Remove="MacOS\**" />
<EmbeddedResource Remove="Tizen\**" />
<EmbeddedResource Remove="WPF\**" />
<None Remove="GTK\**" />
<None Remove="MacOS\**" />
<None Remove="Tizen\**" />
<None Remove="WPF\**" />
<Page Remove="**\WPF\**\*.xaml" />
<MauiXaml Remove="**\WPF\**\*.xaml" />
Expand All @@ -53,13 +50,7 @@
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('tizen')) ">
<Compile Include="$(TizenRoot)**\*.cs" />
<EmbeddedResource Include="$(TizenRoot)Resources\*.resx" />
<EmbeddedResource Include="$(TizenRoot)Resources\*.png" />
</ItemGroup>

<ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
Expand Down
5 changes: 5 additions & 0 deletions src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ public void SetVirtualView(Maui.IElement view)
{
throw new NotImplementedException();
}

public void Invoke(string command, object args)
{
throw new NotImplementedException();
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ void OnInnerLayoutUpdate()

void OnCurrentPageChanged(object sender, EventArgs e)
{
CustomFocusManager.StartReorderTabIndex();

Element.UpdateFocusTreePolicy();

if (IsChangedByScroll())
Expand Down
103 changes: 0 additions & 103 deletions src/Compatibility/Core/src/Tizen/Renderers/CustomFocusManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,15 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
class CustomFocusManager : IDisposable
{
static bool s_reorderTriggered;
static readonly ObservableCollection<CustomFocusManager> s_tabIndexList = new ObservableCollection<CustomFocusManager>();

VisualElement _nextUp;
VisualElement _nextDown;
VisualElement _nextLeft;
VisualElement _nextRight;
VisualElement _nextForward;
VisualElement _nextBackward;
int _tabIndex = -1;
bool _isTabStop = true;

static CustomFocusManager()
{
s_tabIndexList.CollectionChanged += TabIndexCollectionChanged;
}

public CustomFocusManager(VisualElement element, Widget nativeView)
Expand All @@ -40,52 +34,6 @@ public CustomFocusManager(VisualElement element, Widget nativeView)
VisualElement Element { get; }
Widget NativeView { get; }

public int TabIndex
{
get
{
return _tabIndex;
}
set
{
if (IsTabStop)
{
if (_tabIndex > -1)
{
s_tabIndexList.Remove(this);
}
if (value > -1)
{
s_tabIndexList.Add(this);
}
}
_tabIndex = value;
}
}

public bool IsTabStop
{
get
{
return _isTabStop;
}
set
{
if (TabIndex > -1)
{
if (_isTabStop)
{
s_tabIndexList.Remove(this);
}
if (value)
{
s_tabIndexList.Add(this);
}
}
_isTabStop = value;
}
}

public VisualElement NextUp
{
get => _nextUp;
Expand Down Expand Up @@ -152,23 +100,6 @@ public void Dispose()
GC.SuppressFinalize(this);
}

public static void StartReorderTabIndex()
{
if (Device.IsInvokeRequired)
{
Device.BeginInvokeOnMainThread(() =>
{
StartReorderTabIndex();
});
return;
}
if (!s_reorderTriggered)
{
s_reorderTriggered = true;
Device.BeginInvokeOnMainThread(ReorderTabIndex);
}
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down Expand Up @@ -198,10 +129,6 @@ protected virtual void Dispose(bool disposing)
NextBackward.PropertyChanged -= OnNextViewPropertyChanged;
}
}
if (s_tabIndexList.Contains(this))
{
s_tabIndexList.Remove(this);
}
}

void SetUpFocus(VisualElement next, FocusDirection direction)
Expand Down Expand Up @@ -251,36 +178,6 @@ FocusDirection GetFocusDirection(VisualElement nextView)
return FocusDirection.Next;
}

static void ReorderTabIndex()
{
s_reorderTriggered = false;
var list = s_tabIndexList.Where((t) => t.IsTabStop && ElementIsVisible(t)).OrderBy(x => x.Element.TabIndex);
CustomFocusManager first = null;
CustomFocusManager last = null;
foreach (var item in list)
{
if (first == null)
first = item;

if (last != null)
{
item.NextBackward = last.Element;
last.NextForward = item.Element;
}
last = item;
}
if (first != null && last != null)
{
first.NextBackward = last.Element;
last.NextForward = first.Element;
}
}

static void TabIndexCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
StartReorderTabIndex();
}

static bool PageIsVisible(Page page)
{
if (page == null)
Expand Down
9 changes: 1 addition & 8 deletions src/Compatibility/Core/src/Tizen/Renderers/EntryRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,7 @@ void OnTextChanged(object sender, EventArgs e)

void OnCompleted(object sender, EventArgs e)
{
if (Element.ReturnType == ReturnType.Next)
{
FocusSearch(true)?.SetFocus(true);
}
else
{
Control.SetFocus(false);
}
Control.SetFocus(false);
((IEntryController)Element).SendCompleted();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ void UpdateDetail(bool isInit)

void UpdateIsPresented()
{
// To update TabIndex order
CustomFocusManager.StartReorderTabIndex();

_flyoutPage.IsPresented = Element.IsPresented;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ void UpdateDetailPage(bool isInit)

void UpdateIsPresented()
{
// To update TabIndex order
CustomFocusManager.StartReorderTabIndex();

_mdpage.IsPresented = Element.IsPresented;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,6 @@ void OnToolbarItemSelected(object sender, EToolbarItemEventArgs e)

void OnCurrentPageChanged()
{
// To update TabIndex order
CustomFocusManager.StartReorderTabIndex();

if (_isUpdateByScroller || _isUpdateByToolbar || !_isInitialized)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ protected VisualElementRenderer()
RegisterPropertyHandler(VisualElement.RotationYProperty, UpdateTransformation);
RegisterPropertyHandler(VisualElement.TranslationXProperty, UpdateTransformation);
RegisterPropertyHandler(VisualElement.TranslationYProperty, UpdateTransformation);
RegisterPropertyHandler(VisualElement.TabIndexProperty, UpdateTabIndex);
RegisterPropertyHandler(VisualElement.IsTabStopProperty, UpdateIsTabStop);

RegisterPropertyHandler(AutomationProperties.NameProperty, SetAccessibilityName);
RegisterPropertyHandler(AutomationProperties.HelpTextProperty, SetAccessibilityDescription);
Expand Down Expand Up @@ -508,29 +506,6 @@ protected virtual void SetLabeledBy(bool initialize)
}
}

protected Widget FocusSearch(bool forwardDirection)
{
VisualElement element = Element as VisualElement;
int maxAttempts = 0;
var tabIndexes = element?.GetTabIndexesOnParentPage(out maxAttempts);
if (tabIndexes == null)
return null;

int tabIndex = Element.TabIndex;
int attempt = 0;

do
{
element = element.FindNextElement(forwardDirection, tabIndexes, ref tabIndex) as VisualElement;
var renderer = Platform.GetRenderer(element);
if (renderer?.NativeView is Widget widget && widget.IsFocusAllowed)
{
return widget;
}
} while (!(element.IsFocused || ++attempt >= maxAttempts));
return null;
}

internal virtual void SendVisualElementInitialized(VisualElement element, EvasObject nativeView)
{
element.SendViewInitialized(nativeView);
Expand Down Expand Up @@ -1212,32 +1187,6 @@ protected virtual void ApplyTransformation()
}
}

void UpdateTabIndex()
{
if (!Forms.Flags.Contains(Flags.DisableTabIndex))
{
if (Element is View && NativeView is Widget widget && widget.IsFocusAllowed)
{
_customFocusManager.Value.TabIndex = Element.TabIndex;
}
}
}

void UpdateIsTabStop(bool init)
{
if (init && Element.IsTabStop)
{
return;
}
if (!Forms.Flags.Contains(Flags.DisableTabIndex))
{
if (Element is View && NativeView is Widget widget && widget.IsFocusAllowed)
{
_customFocusManager.Value.IsTabStop = Element.IsTabStop;
}
}
}

EFocusDirection ConvertToNativeFocusDirection(string direction)
{
if (direction == XFocusDirection.Back)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ public static void MapBorder(BordelessEntryHandler handler, BordelessEntry borde
public static void MapBorder(BordelessEntryHandler handler, BordelessEntry borderlessEntry)
{
}
#else
#elif TIZEN
public static void MapBorder(BordelessEntryHandler handler, BordelessEntry borderlessEntry)
{
}
#elif TIZEN
#else
public static void MapBorder(BordelessEntryHandler handler, BordelessEntry borderlessEntry)
{

}
#endif
}
Expand Down
Loading

0 comments on commit ff48053

Please sign in to comment.