private void ProcessUpdate() { InitializationRoutines.InitPostUpdate(); var dispatcher = ResourceLocator.DispatcherAdapter; ApplicationData.Current.LocalSettings.Values["AppVersion"] = UWPUtilities.GetAppVersion(); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Instance = this; // Override point for customization after application launch. // If not required for your application you can safely delete this method InitializationRoutines.Initialize(AdaptersRegistration); return(true); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); ////var pageDefinitions = new Dictionary<PageIndex, IPageProvider<NavigationFragmentBase>> ////{ //// // cached //// {PageIndex.PageA, new CachedPageProvider<TestPageAFragment>()}, //// // oneshots //// {PageIndex.PageB, new OneshotPageProvider<TestPageBFragment>()}, ////}; var dialogDefinitions = new Dictionary <DialogIndex, ICustomDialogProvider> { { DialogIndex.TestDialogA, new OneshotCustomDialogProvider <TestDialogA>() }, { DialogIndex.TestDialogB, new OneshotCustomDialogProvider <TestDialogB>() } }; var manager = new NavigationManager <PageIndex>( SupportFragmentManager, RootView, new ViewModelResolver()); var dialogManager = new CustomDialogsManager <DialogIndex>( SupportFragmentManager, dialogDefinitions, new ViewModelResolver()); // usually you would do it in Application class but for showcase sake I will skip that InitializationRoutines.Initialize(builder => { builder.RegisterType <ClipboardProvider>().As <IClipboardProvider>().SingleInstance(); builder.RegisterType <DispatcherAdapter>().As <IDispatcherAdapter>().SingleInstance(); builder.RegisterType <FileStorageProvider>().As <IFileStorageProvider>().SingleInstance(); builder.RegisterType <MessageBoxProvider>().As <IMessageBoxProvider>().SingleInstance(); builder.RegisterType <SettingsProvider>().As <ISettingsProvider>().SingleInstance(); builder.RegisterType <UriLauncherAdapter>().As <IUriLauncherAdapter>().SingleInstance(); builder.RegisterType <VersionProvider>().As <IVersionProvider>().SingleInstance(); builder.RegisterType <PickerAdapter>().As <IPickerAdapter>().SingleInstance(); builder.RegisterType <ContextProvider>().As <IContextProvider>().SingleInstance(); builder.RegisterType <PhotoPickerAdapter>().As <IPhotoPickerAdapter>().SingleInstance(); builder.RegisterType <PhoneCallAdapter>().As <IPhoneCallAdapter>().SingleInstance(); builder.RegisterType <DataCache>().As <IDataCache>().SingleInstance(); builder.RegisterInstance(manager).As <INavigationManager <PageIndex> >(); builder.RegisterInstance(dialogManager).As <ICustomDialogsManager <DialogIndex> >(); }); DialogStyles.PasswordDialogStyle = new PasswordInputDialogStyle(); ViewModelLocator.MainViewModel.Initialize(); }
public override void OnCreate() { //ImageService.Instance.Initialize(new Configuration //{ // FadeAnimationEnabled = true, // FadeAnimationForCachedImages = true, // FadeAnimationDuration = 200, //}); ViewModelLocator.RegisterBase(); AndroidViewModelLocator.RegisterDependencies(); InitializationRoutines.InitApp(); base.OnCreate(); }
public override void OnCreate() { //ImageService.Instance.Initialize(new Configuration //{ // BitmapOptimizations = true, // VerbosePerformanceLogging = true, // Logger = new MiniLogger() //}); var sp = new Stopwatch(); sp.Start(); ImageService.Instance.Initialize(new Configuration { HttpClient = new HttpClient(new NativeMessageHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }), ExecuteCallbacksOnUIThread = true, }); System.Diagnostics.Debug.WriteLine($"ImgSer init {sp.ElapsedMilliseconds}"); sp.Restart(); ViewModelLocator.RegisterBase(); System.Diagnostics.Debug.WriteLine($"RegBase {sp.ElapsedMilliseconds}"); sp.Restart(); AndroidViewModelLocator.RegisterDependencies(); System.Diagnostics.Debug.WriteLine($"RegDep {sp.ElapsedMilliseconds}"); sp.Restart(); InitializationRoutines.InitApp(); System.Diagnostics.Debug.WriteLine($"App init {sp.ElapsedMilliseconds}"); sp.Restart(); ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => { if (certificate.Subject == "CN=*.myanimelist.net" || certificate.Subject == "CN=*.google.com, O=Google Inc, L=Mountain View, S=California, C=US") { return(true); } return(false); }; base.OnCreate(); }
/// <summary> /// Initializes a new instance of the <see cref="App"/> class. /// This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; InitializationRoutines.Initialize(builder => { builder.RegisterType <ClipboardProvider>().As <IClipboardProvider>().SingleInstance(); builder.RegisterType <DispatcherAdapter>().As <IDispatcherAdapter>().SingleInstance(); builder.RegisterType <FileStorageProvider>().As <IFileStorageProvider>().SingleInstance(); builder.RegisterType <MessageBoxProvider>().As <IMessageBoxProvider>().SingleInstance(); builder.RegisterType <SettingsProvider>().As <ISettingsProvider>().SingleInstance(); builder.RegisterType <UriLauncherAdapter>().As <IUriLauncherAdapter>().SingleInstance(); builder.RegisterType <VersionProvider>().As <IVersionProvider>().SingleInstance(); builder.RegisterType <PickerAdapter>().As <IPickerAdapter>().SingleInstance(); builder.RegisterType <PhotoPickerAdapter>().As <IPhotoPickerAdapter>().SingleInstance(); builder.RegisterType <PhoneCallAdapter>().As <IPhoneCallAdapter>().SingleInstance(); builder.RegisterType <DataCache>().As <IDataCache>().SingleInstance(); builder.Register(_ => NavigationManager).As <INavigationManager <PageIndex> >(); builder.Register(_ => DialogManager).As <ICustomDialogsManager <DialogIndex> >(); }); }
protected override async void OnCreate(Bundle bundle) { RequestWindowFeature(WindowFeatures.NoTitle); CurrentTheme = Settings.SelectedTheme; CurrentAccent = AndroidColourThemeHelper.CurrentTheme; SetRightTheme(); ResourceExtension.Init(); base.OnCreate(bundle); if (Resources.DisplayMetrics.WidthPixels >= 1080) { Settings.MakeGridItemsSmaller = true; } AnimeListPageFragment.RightDrawer = null; if (!_addedNavHandlers) { RegisterIoC(); SetContentView(Resource.Layout.MainPage); InitAdContainer(); InitBindings(); ViewModel.MainNavigationRequested += ViewModelOnMainNavigationRequested; ViewModel.MainNavigationRequested += ViewModelOnMainNavigationRequestedFirst; ViewModel.MediaElementCollapsed += ViewModelOnMediaElementCollapsed; ViewModelLocator.AnimeList.DimensionsProvider = this; var args = Intent.Extras?.GetString("launchArgs") ?? Intent.Data?.ToString(); ProcessLaunchArgs(args, true); ViewModel.PerformFirstNavigation(); DroppyMenuPopup.RequestedElevation = DimensionsHelper.DpToPx(10); ResourceLocator.NotificationsTaskManager.StartTask(BgTasks.Notifications); //if ((Resources.Configuration.ScreenLayout & ScreenLayout.SizeMask) == ScreenLayout.SizeSmall) //{ // Settings.PullHigherQualityImages = false; //} DroppyMenuPopup.OverrideRequested += (sender, action) => ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(action)); DroppyMenuPopup.ResetOverrideRequested += (sender, eventArgs) => ViewModelLocator.NavMgr.ResetOneTimeOverride(); //Check permissions var requiredPermission = new List <string>(); if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) != Permission.Granted) { requiredPermission.Add(Manifest.Permission.ReadExternalStorage); } if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) != Permission.Granted) { requiredPermission.Add(Manifest.Permission.WriteExternalStorage); } if (requiredPermission.Any()) { ActivityCompat.RequestPermissions(this, requiredPermission.ToArray(), 129055); } _addedNavHandlers = true; } if (!_staticInitPerformed) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build(); StrictMode.SetThreadPolicy(policy); InitializationRoutines.InitPostUpdate(); await Task.Delay(1000); if (ResourceLocator.ChangelogProvider.NewChangelog) { ChangelogDialog.BuildChangelogDialog(ResourceLocator.ChangelogProvider); } RateReminderPopUp.ProcessRatePopUp(); MemoryWatcher.Watcher.Resume(true); ResourceLocator.TelemetryProvider.Init(); _staticInitPerformed = true; } }
protected async void OnLaunchedOrActivated(IActivatedEventArgs e) { ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(500, 500)); var rootFrame = Window.Current.Content as Frame; Tuple <int, string> navArgs = null; Tuple <PageIndex, object> fullNavArgs = null; var launchArgs = e as LaunchActivatedEventArgs; if (!string.IsNullOrWhiteSpace(launchArgs?.Arguments)) { if (Regex.IsMatch(launchArgs.Arguments, @"[OpenUrl,OpenDetails];.*")) { var options = launchArgs.Arguments.Split(';'); if (options[0] == TileActions.OpenUrl.ToString()) { LaunchUri(options[1]); } else if (launchArgs.Arguments.Contains('|')) //legacy { var detailArgs = options[1].Split('|'); navArgs = new Tuple <int, string>(int.Parse(detailArgs[0]), detailArgs[1]); } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(options[1]); } } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(launchArgs.Arguments); } } else if (e is ProtocolActivatedEventArgs) { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl("https:" + (e as ProtocolActivatedEventArgs).Uri.AbsolutePath); } else { var activationArgs = e as ToastNotificationActivatedEventArgs; if (activationArgs != null) { var arg = activationArgs.Argument; var pos = arg.IndexOf('~'); if (pos != -1) { var id = arg.Substring(0, pos); arg = arg.Substring(pos + 1); MalNotificationsQuery.MarkNotifiactionsAsRead(new MalNotification(id)); } if (arg.Contains(";")) { var options = activationArgs.Argument.Split(';'); if (options[0] == TileActions.OpenUrl.ToString()) { LaunchUri(options[1]); } } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(arg); } } } // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //nothing } if (e.PreviousExecutionState == ApplicationExecutionState.NotRunning) //Crashed - we have to remove cached anime list { if (Settings.IsCachingEnabled) { await DataCache.ClearAnimeListData(); //clear all cached users data } } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (navArgs != null) { MainViewModelBase.InitDetails = navArgs; } else if (fullNavArgs != null) { MainViewModelBase.InitDetailsFull = fullNavArgs; } rootFrame.Navigate(typeof(MainPage)); } else if (navArgs != null) { ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeDetails, new AnimeDetailsPageNavigationArgs(navArgs.Item1, navArgs.Item2, null, null)); } if (_initialized && fullNavArgs != null) { ViewModelLocator.GeneralMain.Navigate(fullNavArgs.Item1, fullNavArgs.Item2); } // Ensure the current window is active if (_initialized) { return; } InitializationRoutines.InitApp(); NotificationTaskManager.StartNotificationTask(BgTasks.ToastActivation, false); NotificationTaskManager.StartNotificationTask(BgTasks.Notifications, false); NotificationTaskManager.OnNotificationTaskRequested += NotificationTaskManagerOnOnNotificationTaskRequested; ImageCache.PerformScheduledCacheCleanup(); LiveTilesManager.LoadTileCache(); Window.Current.Activate(); RateReminderPopUp.ProcessRatePopUp(); ProcessStatusBar(); ProcessUpdate(); StoreLogoWorkaroundHacker.Hack(); _initialized = true; }
private void ProcessUpdate() { InitializationRoutines.InitPostUpdate(); ApplicationData.Current.LocalSettings.Values["AppVersion"] = UWPUtilities.GetAppVersion(); }
private async void OnLaunchedOrActivated(IActivatedEventArgs e) { var rootFrame = Window.Current.Content as Frame; Tuple <int, string> navArgs = null; Tuple <PageIndex, object> fullNavArgs = null; var launchArgs = e as LaunchActivatedEventArgs; if (!string.IsNullOrWhiteSpace(launchArgs?.Arguments)) { if (Regex.IsMatch(launchArgs.Arguments, @"[OpenUrl,OpenDetails];.*")) { var options = launchArgs.Arguments.Split(';'); if (options[0] == TileActions.OpenUrl.ToString()) { LaunchUri(options[1]); } else if (launchArgs.Arguments.Contains('|')) //legacy { var detailArgs = options[1].Split('|'); navArgs = new Tuple <int, string>(int.Parse(detailArgs[0]), detailArgs[1]); } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(options[1]); } } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(launchArgs.Arguments); } } else if (e is ProtocolActivatedEventArgs) { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl("https:" + (e as ProtocolActivatedEventArgs).Uri.OriginalString.Replace("malclient://", "")); } else { var activationArgs = e as ToastNotificationActivatedEventArgs; if (activationArgs != null) { var arg = activationArgs.Argument; var pos = arg.IndexOf('~'); if (pos != -1) { var id = arg.Substring(0, pos); arg = arg.Substring(pos + 1); await MalNotificationsQuery.MarkNotifiactionsAsRead(new MalNotification(id)); } if (arg.Contains(";")) { var options = activationArgs.Argument.Split(';'); if (options[0] == TileActions.OpenUrl.ToString()) { LaunchUri(options[1]); } } else { fullNavArgs = MalLinkParser.GetNavigationParametersForUrl(arg); } } } // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //nothing } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (navArgs != null) { MainViewModelBase.InitDetails = navArgs; } else if (fullNavArgs != null) { MainViewModelBase.InitDetailsFull = fullNavArgs; } rootFrame.Navigate(typeof(MainPage)); } else if (navArgs != null) { ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeDetails, new AnimeDetailsPageNavigationArgs(navArgs.Item1, navArgs.Item2, null, null)); } if (_initialized && fullNavArgs != null) { ViewModelLocator.GeneralMain.Navigate(fullNavArgs.Item1, fullNavArgs.Item2); } // Ensure the current window is active if (_initialized) { return; } await InitializationRoutines.InitApp(); NotificationTaskManager.StartNotificationTask(BgTasks.ToastActivation, false); NotificationTaskManager.StartNotificationTask(BgTasks.Notifications, false); NotificationTaskManager.OnNotificationTaskRequested += NotificationTaskManagerOnOnNotificationTaskRequested; LiveTilesManager.LoadTileCache(); ImageCache.PerformScheduledCacheCleanup(); Window.Current.Activate(); RateReminderPopUp.ProcessRatePopUp(); JumpListManager.InitJumpList(); var tb = ApplicationView.GetForCurrentView().TitleBar; bool dark = Settings.SelectedTheme == (int)ApplicationTheme.Dark; if (dark) { tb.ButtonBackgroundColor = Colors.Transparent; tb.ButtonForegroundColor = Colors.White; tb.ButtonHoverBackgroundColor = Color.FromArgb(30, 255, 255, 255); tb.ButtonHoverForegroundColor = Colors.White; tb.ButtonInactiveBackgroundColor = Colors.Transparent; tb.ButtonInactiveForegroundColor = Colors.Gray; tb.ButtonPressedBackgroundColor = Color.FromArgb(80, 255, 255, 255); tb.ButtonPressedForegroundColor = Colors.White; } else { tb.ButtonBackgroundColor = Colors.Transparent; tb.ButtonForegroundColor = Colors.Black; tb.ButtonHoverBackgroundColor = Color.FromArgb(30, 0, 0, 0); tb.ButtonHoverForegroundColor = Colors.Black; tb.ButtonInactiveBackgroundColor = Colors.Transparent; tb.ButtonInactiveForegroundColor = Colors.Gray; tb.ButtonPressedBackgroundColor = Color.FromArgb(80, 0, 0, 0); tb.ButtonPressedForegroundColor = Colors.Black; } ProcessUpdate(); StoreLogoWorkaroundHacker.Hack(); _initialized = true; }