예제 #1
0
        /// <inheritdoc/>
        protected override void OnCreate(Bundle bundle)
        {
#if DEBUG
            // Allow debugging of JavaScript inside of the WebView.
            // Debugging can be activated in Chrome by calling "chrome://inspect"
            WebView.SetWebContentsDebuggingEnabled(true);
#endif

            // Clear the splash screen theme, which is declared as attribute of the activity.
            SetTheme(Resource.Style.MainTheme);

            _activityResultAwaiter = new ActivityResultAwaiter(this);
            Startup.InitializeApplication(this, _activityResultAwaiter);
            ConsumeActionSendIntentParameter(Intent);

            // Load main window of single page application.
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            // Prepare the webview
            _webView = FindViewById <WebView>(Resource.Id.webView);
            _webView.SetWebViewClient(new HybridWebViewClient(
                                          (url) => OnNavigating(url),
                                          () => OnNavigationCompleted()));

            WebSettings settings = _webView.Settings;
            settings.JavaScriptEnabled = true;
            settings.BlockNetworkLoads = true;                      // only local content allowed
            settings.AllowFileAccess   = false;                     // no local files but from the asset directory
            settings.SetPluginState(WebSettings.PluginState.Off);   // no plugins allowed
            settings.CacheMode = CacheModes.NoCache;                // is already local content
            settings.JavaScriptCanOpenWindowsAutomatically = false; // same as default
            settings.SetSupportMultipleWindows(false);              // same as default
            settings.TextZoom = 100;                                // Ignores system font size, so the app controls the font size
        }
예제 #2
0
 /// <summary>
 /// Sets up the application and initializes the services.
 /// </summary>
 /// <param name="rootActivity">The main activity of the Android app.</param>
 public static void InitializeApplication(Activity rootActivity, ActivityResultAwaiter rootActivityResultWaiter)
 {
     Ioc.Reset();
     RegisterServices(rootActivity, rootActivityResultWaiter);
     StartupShared.RegisterControllers();
     StartupShared.RegisterRazorViews();
     StartupShared.RegisterCloudStorageClientFactory();
 }
예제 #3
0
 /// <summary>
 /// Sets up the application and initializes the services.
 /// </summary>
 /// <param name="rootActivity">The main activity of the Android app.</param>
 public static void InitializeApplication(Activity rootActivity, ActivityResultAwaiter rootActivityResultWaiter)
 {
     // do it only the first time
     if (IsFirstTime())
     {
         RegisterServices(rootActivity, rootActivityResultWaiter);
         StartupShared.RegisterControllers();
         StartupShared.RegisterRazorViews();
         StartupShared.RegisterCloudStorageClientFactory();
     }
 }
예제 #4
0
 private static void RegisterServices(Activity rootActivity, ActivityResultAwaiter rootActivityResultWaiter)
 {
     Ioc.RegisterFactory <IEnvironmentService>(() => new EnvironmentService(OperatingSystem.Android, rootActivity));
     Ioc.RegisterFactory <IHtmlView>(() => rootActivity as IHtmlView);
     Ioc.RegisterFactory <IBaseUrlService>(() => new BaseUrlService());
     Ioc.RegisterFactory <ILanguageService>(() => new LanguageService(new LanguageCodeService().GetSystemLanguageCode()));
     Ioc.RegisterFactory <ISvgIconService>(() => new SvgIconService());
     Ioc.RegisterFactory <INavigationService>(() => new NavigationService(
                                                  Ioc.GetOrCreate <IHtmlView>()));
     Ioc.RegisterFactory <INativeBrowserService>(() => new NativeBrowserService(rootActivity));
     Ioc.RegisterFactory <IXmlFileService>(() => new XmlFileService());
     Ioc.RegisterFactory <IVersionService>(() => new VersionService(rootActivity));
     Ioc.RegisterFactory <ISettingsService>(() => new SettingsService(
                                                rootActivity,
                                                Ioc.GetOrCreate <IXmlFileService>(),
                                                Ioc.GetOrCreate <IDataProtectionService>(),
                                                Ioc.GetOrCreate <IEnvironmentService>()));
     Ioc.RegisterFactory <IRepositoryStorageService>(() => new RepositoryStorageService(
                                                         rootActivity,
                                                         Ioc.GetOrCreate <IXmlFileService>(),
                                                         Ioc.GetOrCreate <ILanguageService>()));
     Ioc.RegisterFactory <ICryptoRandomService>(() => new CryptoRandomService());
     Ioc.RegisterFactory <INoteRepositoryUpdater>(() => new NoteRepositoryUpdater());
     Ioc.RegisterFactory <IStoryBoardService>(() => new StoryBoardService());
     Ioc.RegisterFactory <IFeedbackService>(() => new FeedbackService(
                                                rootActivity, Ioc.GetOrCreate <ILanguageService>()));
     Ioc.RegisterFactory <IDataProtectionService>(() => new DataProtectionService(
                                                      rootActivity,
                                                      Ioc.GetOrCreate <ICryptoRandomService>()));
     Ioc.RegisterFactory <IInternetStateService>(() => new InternetStateService(rootActivity));
     Ioc.RegisterFactory <IAutoSynchronizationService>(() => new AutoSynchronizationService(
                                                           Ioc.GetOrCreate <IInternetStateService>(),
                                                           Ioc.GetOrCreate <ISettingsService>(),
                                                           Ioc.GetOrCreate <IRepositoryStorageService>(),
                                                           Ioc.GetOrCreate <INavigationService>()));
     Ioc.RegisterFactory <IThemeService>(() => new ThemeService(
                                             Ioc.GetOrCreate <ISettingsService>(), Ioc.GetOrCreate <IEnvironmentService>()));
     Ioc.RegisterFactory <IFolderPickerService>(() => new FolderPickerService(rootActivity, rootActivityResultWaiter));
 }