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

Commit 719fc7a

Browse files
committed
Merge branch '4.7.0'
# Conflicts: # Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
2 parents 50e72c7 + 21caf89 commit 719fc7a

33 files changed

+798
-35
lines changed

Xamarin.Forms.ControlGallery.Android/FormsAppCompatActivity.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ protected override void OnCreate(Bundle bundle)
9292
return null;
9393
});
9494

95+
DependencyService.Register<IMultiWindowService, MultiWindowService>();
96+
9597
LoadApplication(_app);
9698

9799
#if !TEST_EXPERIMENTAL_RENDERERS
@@ -103,6 +105,11 @@ protected override void OnCreate(Bundle bundle)
103105
#endif
104106
}
105107

108+
public void ReloadApplication()
109+
{
110+
LoadApplication(_app);
111+
}
112+
106113
protected override void OnResume()
107114
{
108115
base.OnResume();
@@ -114,7 +121,26 @@ public bool IsPreAppCompat()
114121
{
115122
return false;
116123
}
124+
125+
[Java.Interop.Export("BackgroundApp")]
126+
public void BackgroundApp()
127+
{
128+
Intent intent = new Intent();
129+
intent.SetAction(Intent.ActionMain);
130+
intent.AddCategory(Intent.CategoryHome);
131+
this.StartActivity(intent);
132+
}
133+
134+
[Java.Interop.Export("ForegroundApp")]
135+
public void ForegroundApp()
136+
{
137+
// this only works pre API 29
138+
Intent intent = new Intent(ApplicationContext, typeof(Activity1));
139+
intent.SetAction(Intent.ActionMain);
140+
intent.AddCategory(Intent.CategoryLauncher);
141+
this.ApplicationContext.StartActivity(intent);
142+
}
117143
}
118144
}
119145

120-
#endif
146+
#endif
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Android.App;
7+
using Android.Content;
8+
using Android.Content.PM;
9+
using Android.OS;
10+
using Android.Renderscripts;
11+
using Android.Runtime;
12+
using Android.Views;
13+
using Android.Widget;
14+
using Xamarin.Forms.Controls.Issues;
15+
16+
namespace Xamarin.Forms.ControlGallery.Android
17+
{
18+
[Activity(Label = "Issue10182Activity", Icon = "@drawable/icon", Theme = "@style/MyTheme",
19+
MainLauncher = false, HardwareAccelerated = true,
20+
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.UiMode)]
21+
public class Issue10182Activity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
22+
{
23+
Activity1 _activity1;
24+
protected override void OnCreate(Bundle savedInstanceState)
25+
{
26+
var currentApplication = Xamarin.Forms.Application.Current;
27+
TabLayoutResource = Resource.Layout.Tabbar;
28+
ToolbarResource = Resource.Layout.Toolbar;
29+
30+
base.OnCreate(savedInstanceState);
31+
32+
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
33+
LoadApplication(new Issue10182Application());
34+
35+
_activity1 = (Activity1)DependencyService.Resolve<Context>();
36+
37+
Device.BeginInvokeOnMainThread(async () =>
38+
{
39+
try
40+
{
41+
42+
await Task.Delay(1000);
43+
{
44+
Intent intent = new Intent(_activity1, typeof(Activity1));
45+
intent.AddFlags(ActivityFlags.ReorderToFront);
46+
_activity1.StartActivity(intent);
47+
}
48+
49+
await Task.Delay(1000);
50+
{
51+
Intent intent = new Intent(this, typeof(Issue10182Activity));
52+
intent.AddFlags(ActivityFlags.ReorderToFront);
53+
StartActivity(intent);
54+
}
55+
56+
await Task.Delay(1000);
57+
{
58+
Intent intent = new Intent(_activity1, typeof(Activity1));
59+
intent.AddFlags(ActivityFlags.ReorderToFront);
60+
_activity1.StartActivity(intent);
61+
}
62+
}
63+
finally
64+
{
65+
this.Finish();
66+
_activity1.ReloadApplication();
67+
currentApplication.MainPage = new Issue10182.Issue10182SuccessPage();
68+
}
69+
});
70+
}
71+
72+
public class Issue10182Test : ContentPage
73+
{
74+
public Issue10182Test()
75+
{
76+
Content = new StackLayout()
77+
{
78+
Children =
79+
{
80+
new Label()
81+
{
82+
Text = "Hold Please. Activity should vanish soon and you'll see a success label",
83+
AutomationId = "Loaded"
84+
}
85+
}
86+
};
87+
}
88+
}
89+
90+
public class Issue10182Application : Application
91+
{
92+
protected override void OnStart()
93+
{
94+
var contentPage = new Issue10182Test();
95+
base.OnStart();
96+
MainPage = contentPage;
97+
}
98+
99+
protected override void OnSleep()
100+
{
101+
base.OnSleep();
102+
MainPage = new NavigationPage(new ContentPage());
103+
}
104+
}
105+
}
106+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#if !FORMS_APPLICATION_ACTIVITY && !PRE_APPLICATION_CLASS
2+
3+
using Android.Content;
4+
using Xamarin.Forms.Controls.Issues;
5+
using System;
6+
7+
namespace Xamarin.Forms.ControlGallery.Android
8+
{
9+
public class MultiWindowService : IMultiWindowService
10+
{
11+
public void OpenWindow(Type type)
12+
{
13+
if (type == typeof(Issue10182))
14+
{
15+
var context = DependencyService.Resolve<Context>();
16+
Intent intent = new Intent(context, typeof(Issue10182Activity));
17+
context.StartActivity(intent);
18+
}
19+
}
20+
}
21+
}
22+
23+
#endif

Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@
104104
<Compile Include="DisposeLabelRenderer.cs" />
105105
<Compile Include="DisposePageRenderer.cs" />
106106
<Compile Include="FormsAppCompatActivity.cs" />
107+
<Compile Include="Issue10182Activity.cs" />
107108
<Compile Include="MainApplication.cs" />
109+
<Compile Include="MultiWindowService.cs" />
108110
<Compile Include="PerformanceTrackerRenderer.cs" />
109111
<Compile Include="PlatformSpecificCoreGalleryFactory.cs" />
110112
<Compile Include="Resources\Resource.Designer.cs" />
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System.Collections.Generic;
2+
using System.Collections.ObjectModel;
3+
using System.Text;
4+
using Xamarin.Forms.CustomAttributes;
5+
using Xamarin.Forms.Internals;
6+
using System.Threading.Tasks;
7+
using System.Threading;
8+
9+
10+
#if UITEST
11+
using Xamarin.UITest;
12+
using NUnit.Framework;
13+
using Xamarin.Forms.Core.UITests;
14+
#endif
15+
16+
namespace Xamarin.Forms.Controls.Issues
17+
{
18+
[Preserve(AllMembers = true)]
19+
[Issue(IssueTracker.Github, 10182, "[Bug] Exception Ancestor must be provided for all pushes except first", PlatformAffected.Android, NavigationBehavior.SetApplicationRoot)]
20+
#if UITEST
21+
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github10000)]
22+
[NUnit.Framework.Category(UITestCategories.LifeCycle)]
23+
#endif
24+
public class Issue10182 : TestContentPage
25+
{
26+
public Issue10182()
27+
{
28+
29+
}
30+
31+
protected override void Init()
32+
{
33+
Content = new StackLayout()
34+
{
35+
Children =
36+
{
37+
new Label()
38+
{
39+
Text = "Starting Activity to Test Changing Page on Resume. If success label shows up test has passed."
40+
}
41+
}
42+
};
43+
44+
#if !UITEST
45+
Device.BeginInvokeOnMainThread(() =>
46+
{
47+
DependencyService.Get<IMultiWindowService>().OpenWindow(this.GetType());
48+
});
49+
#endif
50+
51+
}
52+
53+
public class Issue10182SuccessPage : ContentPage
54+
{
55+
public Issue10182SuccessPage()
56+
{
57+
Content = new StackLayout()
58+
{
59+
Children =
60+
{
61+
new Label()
62+
{
63+
Text = "Success.",
64+
AutomationId = "Success"
65+
}
66+
}
67+
};
68+
}
69+
}
70+
71+
#if UITEST && __ANDROID__
72+
[Test]
73+
public void AppDoesntCrashWhenResettingPage()
74+
{
75+
RunningApp.WaitForElement("Success");
76+
}
77+
#endif
78+
}
79+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Xamarin.Forms.CustomAttributes;
2+
using Xamarin.Forms.Internals;
3+
4+
namespace Xamarin.Forms.Controls.Issues
5+
{
6+
[Preserve(AllMembers = true)]
7+
[Issue(IssueTracker.Github, 10324, "Unable to intercept or disable mouse back button navigation on UWP", PlatformAffected.UWP)]
8+
public class Issue10324 : TestNavigationPage
9+
{
10+
protected override void Init()
11+
{
12+
Navigation.PushAsync(new IssueFirstPage());
13+
}
14+
15+
class IssueFirstPage : ContentPage
16+
{
17+
public IssueFirstPage()
18+
{
19+
Navigation.PushAsync(new IssueTestAlertPage());
20+
}
21+
}
22+
23+
class IssueTestAlertPage : ContentPage
24+
{
25+
public IssueTestAlertPage()
26+
{
27+
Title = "Hit Mouse BackButton/XButton1. An alert will appear (OnBackButtonPressed overridden)";
28+
Content = new StackLayout();
29+
30+
Navigation.PushAsync(new IssueTestBackPage());
31+
}
32+
33+
protected override bool OnBackButtonPressed()
34+
{
35+
DisplayAlert("OnBackButtonPressed", "OnBackButtonPressed", "OK");
36+
return true;
37+
}
38+
}
39+
40+
class IssueTestBackPage : ContentPage
41+
{
42+
public IssueTestBackPage()
43+
{
44+
Title = "Hit Mouse BackButton/XButton1. Page will go back (OnBackButtonPressed not overridden)";
45+
Content = new StackLayout();
46+
}
47+
48+
protected override bool OnBackButtonPressed()
49+
{
50+
return base.OnBackButtonPressed();
51+
}
52+
}
53+
}
54+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Xamarin.Forms.CustomAttributes;
2+
using Xamarin.Forms.Internals;
3+
4+
#if UITEST
5+
using Xamarin.UITest;
6+
using NUnit.Framework;
7+
using Xamarin.Forms.Core.UITests;
8+
#endif
9+
10+
namespace Xamarin.Forms.Controls.Issues
11+
{
12+
#if UITEST
13+
[Category(UITestCategories.ScrollView)]
14+
#endif
15+
[Preserve(AllMembers = true)]
16+
[Issue(IssueTracker.Github, 11106,
17+
"[Bug] ScrollView UWP bug in 4.7.0.968!",
18+
PlatformAffected.UWP)]
19+
public class Issue11106 : TestContentPage
20+
{
21+
protected override void Init()
22+
{
23+
Title = "Issue 11106";
24+
25+
var grid = new Grid();
26+
27+
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
28+
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });
29+
30+
var instructions = new Label
31+
{
32+
Padding = 12,
33+
BackgroundColor = Color.Black,
34+
TextColor = Color.White,
35+
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."
36+
};
37+
38+
var scroll = new ScrollView();
39+
40+
var layout = new StackLayout();
41+
42+
for (int i = 0; i < 30; i++)
43+
{
44+
layout.Children.Add(new Entry());
45+
}
46+
47+
scroll.Content = layout;
48+
49+
grid.Children.Add(instructions);
50+
Grid.SetRow(instructions, 0);
51+
52+
grid.Children.Add(scroll);
53+
Grid.SetRow(scroll, 1);
54+
55+
Content = grid;
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)