Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[housekeeping] Automated PR to fix formatting errors #14404

Merged
merged 1 commit into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Xamarin.Forms.Controls.Issues
[Issue(IssueTracker.Github, 4143, "Span inaccuracies", PlatformAffected.Android)]
public partial class Issue4143 : TestContentPage
{
Color[] _colors = new Color[]{ Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.Brown, Color.Purple, Color.Orange, Color.Gray };
Color[] _colors = new Color[] { Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.Brown, Color.Purple, Color.Orange, Color.Gray };
Random _rand = new Random();

protected override void Init()
Expand All @@ -23,7 +23,7 @@ protected override void Init()
#endif
}

#if APP
#if APP
void OnLink1Tapped(object sender, EventArgs e)
{
SetRandomBackgroundColor(Link1);
Expand Down Expand Up @@ -53,7 +53,7 @@ void SetRandomBackgroundColor(Span span)
do
{
newColor = _colors[_rand.Next(_colors.Length)];
} while(oldColor == newColor);
} while (oldColor == newColor);

span.BackgroundColor = newColor;
}
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.Core/Region.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct Region
{
_inflation = inflation;
}

public static Region FromRectangles(IEnumerable<Rectangle> rectangles)
{
var list = rectangles.ToList();
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.Core/Shell/ShellSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ protected async override Task<Page> OnPopModal(bool animated)
await _owner.Shell.GoToAsync("..", animated);
return page;
}

protected override void OnRemovePage(Page page)
{
if (!_owner.IsVisibleSection || _owner.Shell.NavigationManager.AccumulateNavigatedEvents)
Expand Down
13 changes: 7 additions & 6 deletions Xamarin.Forms.Platform.Android/Extensions/TextViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static void RecalculateSpanPositions(this TextView textView, Label elemen
var padding = element.Padding;
var padLeft = (int)textView.Context.ToPixels(padding.Left);
var padTop = (int)textView.Context.ToPixels(padding.Top);

for (int i = 0; i < spannableString.Length(); i = next)
{
var type = Java.Lang.Class.FromType(typeof(Java.Lang.Object));
Expand All @@ -111,7 +111,7 @@ public static void RecalculateSpanPositions(this TextView textView, Label elemen

// get all spans in the range - Android can have overlapping spans
var spans = spannableString.GetSpans(i, next, type);

var startSpan = spans[0];
var endSpan = spans[spans.Length - 1];

Expand All @@ -120,22 +120,23 @@ public static void RecalculateSpanPositions(this TextView textView, Label elemen

var spanStartLine = layout.GetLineForOffset(spanStartOffset);
var spanEndLine = layout.GetLineForOffset(spanEndOffset);

// go through all lines that are affected by the span and calculate a rectangle for each
var spanRectangles = new List<Rectangle>();
for (var curLine = spanStartLine; curLine <= spanEndLine; curLine++)
{
global::Android.Graphics.Rect bounds = new global::Android.Graphics.Rect();
layout.GetLineBounds(curLine, bounds);

var lineHeight = bounds.Height();
var lineStartOffset = layout.GetLineStart(curLine);
var lineVisibleEndOffset = layout.GetLineVisibleEnd(curLine);

var startOffset = (curLine == spanStartLine) ? spanStartOffset : lineStartOffset;
var spanStartX = (int)layout.GetPrimaryHorizontal(startOffset);

var endOffset = (curLine == spanEndLine) ? spanEndOffset : lineVisibleEndOffset;;
var endOffset = (curLine == spanEndLine) ? spanEndOffset : lineVisibleEndOffset;
;
var spanEndX = (int)layout.GetSecondaryHorizontal(endOffset);

var spanWidth = spanEndX - spanStartX;
Expand Down