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

Commit

Permalink
Merge branch '4.7.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
  • Loading branch information
PureWeen committed Jun 25, 2020
2 parents 50e72c7 + 21caf89 commit 719fc7a
Show file tree
Hide file tree
Showing 33 changed files with 798 additions and 35 deletions.
28 changes: 27 additions & 1 deletion Xamarin.Forms.ControlGallery.Android/FormsAppCompatActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ protected override void OnCreate(Bundle bundle)
return null;
});

DependencyService.Register<IMultiWindowService, MultiWindowService>();

LoadApplication(_app);

#if !TEST_EXPERIMENTAL_RENDERERS
Expand All @@ -103,6 +105,11 @@ protected override void OnCreate(Bundle bundle)
#endif
}

public void ReloadApplication()
{
LoadApplication(_app);
}

protected override void OnResume()
{
base.OnResume();
Expand All @@ -114,7 +121,26 @@ public bool IsPreAppCompat()
{
return false;
}

[Java.Interop.Export("BackgroundApp")]
public void BackgroundApp()
{
Intent intent = new Intent();
intent.SetAction(Intent.ActionMain);
intent.AddCategory(Intent.CategoryHome);
this.StartActivity(intent);
}

[Java.Interop.Export("ForegroundApp")]
public void ForegroundApp()
{
// this only works pre API 29
Intent intent = new Intent(ApplicationContext, typeof(Activity1));
intent.SetAction(Intent.ActionMain);
intent.AddCategory(Intent.CategoryLauncher);
this.ApplicationContext.StartActivity(intent);
}
}
}

#endif
#endif
106 changes: 106 additions & 0 deletions Xamarin.Forms.ControlGallery.Android/Issue10182Activity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Renderscripts;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Xamarin.Forms.Controls.Issues;

namespace Xamarin.Forms.ControlGallery.Android
{
[Activity(Label = "Issue10182Activity", Icon = "@drawable/icon", Theme = "@style/MyTheme",
MainLauncher = false, HardwareAccelerated = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.UiMode)]
public class Issue10182Activity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
Activity1 _activity1;
protected override void OnCreate(Bundle savedInstanceState)
{
var currentApplication = Xamarin.Forms.Application.Current;
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;

base.OnCreate(savedInstanceState);

global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new Issue10182Application());

_activity1 = (Activity1)DependencyService.Resolve<Context>();

Device.BeginInvokeOnMainThread(async () =>
{
try
{

await Task.Delay(1000);
{
Intent intent = new Intent(_activity1, typeof(Activity1));
intent.AddFlags(ActivityFlags.ReorderToFront);
_activity1.StartActivity(intent);
}

await Task.Delay(1000);
{
Intent intent = new Intent(this, typeof(Issue10182Activity));
intent.AddFlags(ActivityFlags.ReorderToFront);
StartActivity(intent);
}

await Task.Delay(1000);
{
Intent intent = new Intent(_activity1, typeof(Activity1));
intent.AddFlags(ActivityFlags.ReorderToFront);
_activity1.StartActivity(intent);
}
}
finally
{
this.Finish();
_activity1.ReloadApplication();
currentApplication.MainPage = new Issue10182.Issue10182SuccessPage();
}
});
}

public class Issue10182Test : ContentPage
{
public Issue10182Test()
{
Content = new StackLayout()
{
Children =
{
new Label()
{
Text = "Hold Please. Activity should vanish soon and you'll see a success label",
AutomationId = "Loaded"
}
}
};
}
}

public class Issue10182Application : Application
{
protected override void OnStart()
{
var contentPage = new Issue10182Test();
base.OnStart();
MainPage = contentPage;
}

protected override void OnSleep()
{
base.OnSleep();
MainPage = new NavigationPage(new ContentPage());
}
}
}
}
23 changes: 23 additions & 0 deletions Xamarin.Forms.ControlGallery.Android/MultiWindowService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#if !FORMS_APPLICATION_ACTIVITY && !PRE_APPLICATION_CLASS

using Android.Content;
using Xamarin.Forms.Controls.Issues;
using System;

namespace Xamarin.Forms.ControlGallery.Android
{
public class MultiWindowService : IMultiWindowService
{
public void OpenWindow(Type type)
{
if (type == typeof(Issue10182))
{
var context = DependencyService.Resolve<Context>();
Intent intent = new Intent(context, typeof(Issue10182Activity));
context.StartActivity(intent);
}
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@
<Compile Include="DisposeLabelRenderer.cs" />
<Compile Include="DisposePageRenderer.cs" />
<Compile Include="FormsAppCompatActivity.cs" />
<Compile Include="Issue10182Activity.cs" />
<Compile Include="MainApplication.cs" />
<Compile Include="MultiWindowService.cs" />
<Compile Include="PerformanceTrackerRenderer.cs" />
<Compile Include="PlatformSpecificCoreGalleryFactory.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System.Threading.Tasks;
using System.Threading;


#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 10182, "[Bug] Exception Ancestor must be provided for all pushes except first", PlatformAffected.Android, NavigationBehavior.SetApplicationRoot)]
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github10000)]
[NUnit.Framework.Category(UITestCategories.LifeCycle)]
#endif
public class Issue10182 : TestContentPage
{
public Issue10182()
{

}

protected override void Init()
{
Content = new StackLayout()
{
Children =
{
new Label()
{
Text = "Starting Activity to Test Changing Page on Resume. If success label shows up test has passed."
}
}
};

#if !UITEST
Device.BeginInvokeOnMainThread(() =>
{
DependencyService.Get<IMultiWindowService>().OpenWindow(this.GetType());
});
#endif

}

public class Issue10182SuccessPage : ContentPage
{
public Issue10182SuccessPage()
{
Content = new StackLayout()
{
Children =
{
new Label()
{
Text = "Success.",
AutomationId = "Success"
}
}
};
}
}

#if UITEST && __ANDROID__
[Test]
public void AppDoesntCrashWhenResettingPage()
{
RunningApp.WaitForElement("Success");
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 10324, "Unable to intercept or disable mouse back button navigation on UWP", PlatformAffected.UWP)]
public class Issue10324 : TestNavigationPage
{
protected override void Init()
{
Navigation.PushAsync(new IssueFirstPage());
}

class IssueFirstPage : ContentPage
{
public IssueFirstPage()
{
Navigation.PushAsync(new IssueTestAlertPage());
}
}

class IssueTestAlertPage : ContentPage
{
public IssueTestAlertPage()
{
Title = "Hit Mouse BackButton/XButton1. An alert will appear (OnBackButtonPressed overridden)";
Content = new StackLayout();

Navigation.PushAsync(new IssueTestBackPage());
}

protected override bool OnBackButtonPressed()
{
DisplayAlert("OnBackButtonPressed", "OnBackButtonPressed", "OK");
return true;
}
}

class IssueTestBackPage : ContentPage
{
public IssueTestBackPage()
{
Title = "Hit Mouse BackButton/XButton1. Page will go back (OnBackButtonPressed not overridden)";
Content = new StackLayout();
}

protected override bool OnBackButtonPressed()
{
return base.OnBackButtonPressed();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.ScrollView)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 11106,
"[Bug] ScrollView UWP bug in 4.7.0.968!",
PlatformAffected.UWP)]
public class Issue11106 : TestContentPage
{
protected override void Init()
{
Title = "Issue 11106";

var grid = new Grid();

grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });

var instructions = new Label
{
Padding = 12,
BackgroundColor = Color.Black,
TextColor = Color.White,
Text = "Scroll to the end and try to set focus to the last Entry. If you can tap the Entry and set the focus, the test has passed."
};

var scroll = new ScrollView();

var layout = new StackLayout();

for (int i = 0; i < 30; i++)
{
layout.Children.Add(new Entry());
}

scroll.Content = layout;

grid.Children.Add(instructions);
Grid.SetRow(instructions, 0);

grid.Children.Add(scroll);
Grid.SetRow(scroll, 1);

Content = grid;
}
}
}
Loading

0 comments on commit 719fc7a

Please sign in to comment.