Exemplo n.º 1
0
        static Task PlatformOpenAsync(Uri uri, BrowserLaunchMode launchMode)
        {
            var nativeUri = AndroidUri.Parse(uri.AbsoluteUri);

            switch (launchMode)
            {
            case BrowserLaunchMode.SystemPreferred:
                var tabsBuilder = new CustomTabsIntent.Builder();
                tabsBuilder.SetShowTitle(true);
                var tabsIntent = tabsBuilder.Build();
                tabsIntent.Intent.SetFlags(ActivityFlags.ClearTop);
                tabsIntent.Intent.SetFlags(ActivityFlags.NewTask);
                tabsIntent.LaunchUrl(Platform.AppContext, nativeUri);
                break;

            case BrowserLaunchMode.External:
                var intent = new Intent(Intent.ActionView, nativeUri);
                intent.SetFlags(ActivityFlags.ClearTop);
                intent.SetFlags(ActivityFlags.NewTask);

                if (!Platform.IsIntentSupported(intent))
                {
                    throw new FeatureNotSupportedException();
                }

                Platform.AppContext.StartActivity(intent);
                break;
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        public void OpenWebViewCommandTests()
        {
            var reAgreeTermsOfServicePageViewModel = CreateViewModel();
            var termsOfServiceDetail = new TermsUpdateInfoModel.Detail {
                Text = "利用規約テキスト", UpdateDateTimeJst = new DateTime(2020, 11, 01)
            };

            var param = ReAgreeTermsOfServicePage.BuildNavigationParams(termsOfServiceDetail);

            reAgreeTermsOfServicePageViewModel.Initialize(param);

            var               actualCalls      = 0;
            string            actualUri        = default;
            BrowserLaunchMode actualLaunchMode = default;

            reAgreeTermsOfServicePageViewModel.BrowserOpenAsync = (uri, launchMode) =>
            {
                actualCalls++;
                actualUri        = uri;
                actualLaunchMode = launchMode;
                return(Task.CompletedTask);
            };

            reAgreeTermsOfServicePageViewModel.OpenWebView.Execute(null);

            Assert.Equal(1, actualCalls);
            Assert.Equal(AppResources.UrlTermOfUse, actualUri);
            Assert.Equal(BrowserLaunchMode.SystemPreferred, actualLaunchMode);
        }
Exemplo n.º 3
0
        public void OpenWebViewCommandTests()
        {
            var reAgreePrivacyPolicyPageViewModel = CreateViewModel();
            var param = new NavigationParameters
            {
                { "updatePrivacyPolicyInfo", new TermsUpdateInfoModel.Detail {
                      Text = "", UpdateDateTime = DateTime.Now
                  } }
            };

            reAgreePrivacyPolicyPageViewModel.Initialize(param);

            var               actualCalls      = 0;
            string            actualUri        = default;
            BrowserLaunchMode actualLaunchMode = default;

            reAgreePrivacyPolicyPageViewModel.BrowserOpenAsync = (uri, launchMode) =>
            {
                actualCalls++;
                actualUri        = uri;
                actualLaunchMode = launchMode;
                return(Task.CompletedTask);
            };

            reAgreePrivacyPolicyPageViewModel.OpenWebView.Execute(null);

            Assert.Equal(1, actualCalls);
            Assert.Equal("https://www.mhlw.go.jp/cocoa/privacypolicy_english.html", actualUri);
            Assert.Equal(BrowserLaunchMode.SystemPreferred, actualLaunchMode);
        }
        public void OpenWebViewCommandTests()
        {
            var reAgreePrivacyPolicyPageViewModel = CreateViewModel();

            var updateInfo = new TermsUpdateInfoModel
            {
                PrivacyPolicy = new TermsUpdateInfoModel.Detail {
                    Text = "test", UpdateDateTimeJst = DateTime.Now
                }
            };

            var param = ReAgreePrivacyPolicyPage.BuildNavigationParams(updateInfo.PrivacyPolicy, Destination.HomePage);

            reAgreePrivacyPolicyPageViewModel.Initialize(param);

            var               actualCalls      = 0;
            string            actualUri        = default;
            BrowserLaunchMode actualLaunchMode = default;

            reAgreePrivacyPolicyPageViewModel.BrowserOpenAsync = (uri, launchMode) =>
            {
                actualCalls++;
                actualUri        = uri;
                actualLaunchMode = launchMode;
                return(Task.CompletedTask);
            };

            reAgreePrivacyPolicyPageViewModel.OpenWebView.Execute(null);

            Assert.Equal(1, actualCalls);
            Assert.Equal(AppResources.UrlPrivacyPolicy, actualUri);
            Assert.Equal(BrowserLaunchMode.SystemPreferred, actualLaunchMode);
        }
Exemplo n.º 5
0
        public static Task OpenAsync(string uri, BrowserLaunchMode launchMode)
        {
            if (string.IsNullOrWhiteSpace(uri))
            {
                throw new ArgumentNullException(nameof(uri), $"Uri cannot be empty.");
            }

            return(OpenAsync(new Uri(uri), launchMode));
        }
 private async void OpenBrowserAsync(BrowserLaunchMode mode)
 {
     await Browser.OpenAsync(Property.NeighbourhoodUrl, new BrowserLaunchOptions
     {
         LaunchMode            = mode,
         TitleMode             = BrowserTitleMode.Default,
         PreferredControlColor = Color.White,
         PreferredToolbarColor = Color.FromHex("#2196F3")
     });
 }
Exemplo n.º 7
0
 public Task OpenAsync(Uri uri, BrowserLaunchMode launchMode)
 {
     try
     {
         return(Xamarin.Essentials.Browser.OpenAsync(uri, launchMode));
     }
     catch (Exception ex)
     {
         _eventTracker.Error(ex);
         return(Task.CompletedTask);
     }
 }
Exemplo n.º 8
0
 public Task OpenAsync(Uri uri, BrowserLaunchMode launchMode)
 {
     return(OpenAsync
            (
                uri,
                new BrowserLaunchOptions
     {
         Flags = BrowserLaunchFlags.None,
         LaunchMode = launchMode,
         TitleMode = BrowserTitleMode.Default
     }
            ));
 }
Exemplo n.º 9
0
        public void OnClickQuestionCommandTests()
        {
            var unitUnderTest = CreateViewModel();
            unitUnderTest.Initialize(new NavigationParameters());

            var actualCalls = 0;
            string actualUri = default;
            BrowserLaunchMode actualLaunchMode = default;
            unitUnderTest.BrowserOpenAsync = (uri, launchMode) =>
            {
                actualCalls++;
                actualUri = uri;
                actualLaunchMode = launchMode;
                return Task.CompletedTask;
            };

            unitUnderTest.OnClickQuestionCommand.Execute(null);

            Assert.Equal(1, actualCalls);
            Assert.Equal("https://www.mhlw.go.jp/stf/seisakunitsuite/bunya/kenkou_iryou/covid19_qa_kanrenkigyou_00009.html", actualUri);
            Assert.Equal(BrowserLaunchMode.SystemPreferred, actualLaunchMode);
        }
Exemplo n.º 10
0
        public void OpenWebViewCommandTests()
        {
            var reAgreeTermsOfServicePageViewModel = CreateViewModel();
            var updateInfo = new TermsUpdateInfoModel
            {
                TermsOfService = new TermsUpdateInfoModel.Detail {
                    Text = "利用規約テキスト", UpdateDateTime = new DateTime(2020, 11, 01)
                },
                PrivacyPolicy = new TermsUpdateInfoModel.Detail {
                    Text = "プライバシーポリシーテキスト", UpdateDateTime = new DateTime(2020, 11, 02)
                }
            };
            var param = new NavigationParameters
            {
                { "updateInfo", updateInfo }
            };

            reAgreeTermsOfServicePageViewModel.Initialize(param);

            var               actualCalls      = 0;
            string            actualUri        = default;
            BrowserLaunchMode actualLaunchMode = default;

            reAgreeTermsOfServicePageViewModel.BrowserOpenAsync = (uri, launchMode) =>
            {
                actualCalls++;
                actualUri        = uri;
                actualLaunchMode = launchMode;
                return(Task.CompletedTask);
            };

            reAgreeTermsOfServicePageViewModel.OpenWebView.Execute(null);

            Assert.Equal(1, actualCalls);
            Assert.Equal("https://www.mhlw.go.jp/cocoa/kiyaku_english.html", actualUri);
            Assert.Equal(BrowserLaunchMode.SystemPreferred, actualLaunchMode);
        }
Exemplo n.º 11
0
        static Task PlatformOpenAsync(Uri uri, BrowserLaunchMode launchMode)
        {
            var nativeUrl = new NSUrl(uri.AbsoluteUri);

            switch (launchMode)
            {
            case BrowserLaunchMode.SystemPreferred:
                var sfViewController = new SFSafariViewController(nativeUrl, false);
                var vc = Platform.GetCurrentViewController();

                if (sfViewController.PopoverPresentationController != null)
                {
                    sfViewController.PopoverPresentationController.SourceView = vc.View;
                }
                vc.PresentViewController(sfViewController, true, null);
                break;

            case BrowserLaunchMode.External:
                UIKit.UIApplication.SharedApplication.OpenUrl(nativeUrl);
                break;
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 12
0
        static async Task <bool> PlatformOpenAsync(Uri uri, BrowserLaunchMode launchMode)
        {
            var nativeUrl = new NSUrl(uri.AbsoluteUri);

            switch (launchMode)
            {
            case BrowserLaunchMode.SystemPreferred:
                var sfViewController = new SFSafariViewController(nativeUrl, false);
                var vc = Platform.GetCurrentViewController();

                if (sfViewController.PopoverPresentationController != null)
                {
                    sfViewController.PopoverPresentationController.SourceView = vc.View;
                }
                await vc.PresentViewControllerAsync(sfViewController, true);

                break;

            case BrowserLaunchMode.External:
                return(await UIApplication.SharedApplication.OpenUrlAsync(nativeUrl, new UIApplicationOpenUrlOptions()));
            }

            return(true);
        }
Exemplo n.º 13
0
 public static Task <bool> OpenAsync(Uri uri, BrowserLaunchMode launchMode) =>
 PlatformOpenAsync(EscapeUri(uri), launchMode);
Exemplo n.º 14
0
 public static Task <bool> OpenAsync(Uri uri, BrowserLaunchMode launchMode) => Default.OpenAsync(uri, launchMode);
Exemplo n.º 15
0
 static Task PlatformOpenAsync(Uri uri, BrowserLaunchMode launchType) =>
 Windows.System.Launcher.LaunchUriAsync(uri).AsTask();
Exemplo n.º 16
0
 public static Task OpenAsync(Uri uri, BrowserLaunchMode launchMode) =>
 OpenAsync(uri, new BrowserLaunchOptions()
 {
     LaunchMode = launchMode
 });
 /// <inheritdoc />
 public IObservable <Unit> Open(Uri uri, BrowserLaunchMode launchType) =>
 Observable.FromAsync(() => Browser.OpenAsync(uri, launchType));
Exemplo n.º 18
0
 public static Task <bool> OpenAsync(this IBrowser browser, Uri uri, BrowserLaunchMode launchMode) =>
 browser.OpenAsync(uri, new BrowserLaunchOptions {
     LaunchMode = launchMode
 });
Exemplo n.º 19
0
 static Task PlatformOpenAsync(Uri uri, BrowserLaunchMode launchMode) =>
 throw new NotImplementedInReferenceAssemblyException();
Exemplo n.º 20
0
 public Task OpenAsync(string uri, BrowserLaunchMode launchMode) => OpenAsync(new Uri(uri), new BrowserLaunchOptions {
     LaunchMode = launchMode
 });
Exemplo n.º 21
0
 /// <include file="../../docs/Microsoft.Maui.Essentials/Browser.xml" path="//Member[@MemberName='OpenAsync'][2]/Docs" />
 public static Task OpenAsync(string uri, BrowserLaunchMode launchMode) =>
 Current.OpenAsync(uri, new BrowserLaunchOptions()
 {
     LaunchMode = launchMode
 });
Exemplo n.º 22
0
 public async Task OpenAsync(Uri uri, BrowserLaunchMode launchMode)
 {
     await DispatcherRunTaskAsync(CoreDispatcherPriority.Normal, () => _innerBrowser.OpenAsync(uri, launchMode));
 }