public void onSaveSettings(string nick) { if (selectedLanguage != null) { Application.Current.Properties["language"] = selectedLanguage; } else { resetLanguage(); } Application.Current.Properties["lockenabled"] = lockEnabled; Application.Current.SavePropertiesAsync(); // Force-save properties for compatibility with WPF if (Node.localStorage.nickname != nick) { Node.localStorage.nickname = nick; FriendList.broadcastNicknameChange(); } Node.localStorage.writeAccountFile(); Node.changedSettings = true; applyAvatar(); if (ThemeManager.changeAppearance(selectedAppearance)) { UIHelpers.reloadAllPages(); if (Device.RuntimePlatform == Device.iOS) { return; // iOS automatically pops the current page when reloading contents } } // Pop the current page from the stack Navigation.PopAsync(Config.defaultXamarinAnimations); }
public static string startingScreen = ""; // Which screen to start on private App() { InitializeComponent(); // Fix for issue https://github.com/xamarin/Xamarin.Forms/issues/10712#issuecomment-629394090 Device.SetFlags(new string[] { "anything" }); // check if already started if (Node.Instance == null) { // Prepare the personal folder if (!Directory.Exists(Config.spixiUserFolder)) { Directory.CreateDirectory(Config.spixiUserFolder); } // Init logging Logging.setOptions(5, 1, true); Logging.start(Config.spixiUserFolder); Logging.info(string.Format("Starting Spixi {0} ({1})", Config.version, CoreConfig.version)); // Init fatal exception handlers AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException; // Load or generate a device ID. if (Application.Current.Properties.ContainsKey("uid")) { byte[] uid = Application.Current.Properties["uid"] as byte[]; if (uid == null) { // Generate and save the device ID Application.Current.Properties["uid"] = CoreConfig.device_id; } else { CoreConfig.device_id = uid; } } else { // Generate and save the device ID Application.Current.Properties["uid"] = CoreConfig.device_id; } if (Application.Current.Properties.ContainsKey("language")) { if (!SpixiLocalization.loadLanguage(Application.Current.Properties["language"] as string)) { Application.Current.Properties["language"] = SpixiLocalization.getCurrentLanguage(); Application.Current.SavePropertiesAsync(); // Force-save properties for compatibility with WPF } } else { string lang = CultureInfo.CurrentCulture.Name.ToLower(); if (SpixiLocalization.loadLanguage(lang)) { Xamarin.Forms.Application.Current.Properties["language"] = SpixiLocalization.getCurrentLanguage(); Xamarin.Forms.Application.Current.SavePropertiesAsync(); // Force-save properties for compatibility with WPF } } movePersonalFiles(); // Load theme and appearance OSAppTheme currentTheme = Application.Current.RequestedTheme; Current.UserAppTheme = currentTheme; ThemeAppearance themeAppearance = ThemeAppearance.automatic; if (Application.Current.Properties.ContainsKey("appearance")) { themeAppearance = (ThemeAppearance)Current.Properties["appearance"]; } ThemeManager.loadTheme("spixiui", themeAppearance); Current.RequestedThemeChanged += (s, a) => { // Respond to the theme change Current.UserAppTheme = a.RequestedTheme; if (ThemeManager.getActiveAppearance() == ThemeAppearance.automatic) { ThemeManager.changeAppearance(ThemeAppearance.automatic); } UIHelpers.reloadAllPages(); }; // Start Ixian code node = new Node(); // Attempt to load a pre-existing wallet bool wallet_found = Node.checkForExistingWallet(); if (!wallet_found) { // Wallet not found, go to initial launch page MainPage = new NavigationPage(new SPIXI.LaunchPage()); } else { // Wallet found, see if it can be decrypted bool wallet_decrypted = IxianHandler.getWalletList().Count > 0 ? IxianHandler.getWalletStorage().isLoaded() : false; if (!wallet_decrypted) { wallet_decrypted = Node.loadWallet(); } if (wallet_decrypted == false) { MainPage = new NavigationPage(new SPIXI.LaunchRetryPage()); } else { // Wallet found if (isLockEnabled()) { // Show the lock screen MainPage = new NavigationPage(new SPIXI.LockPage()); } else { // Show the home screen MainPage = new NavigationPage(HomePage.Instance()); } } } NavigationPage.SetHasNavigationBar(MainPage, false); } else { // Already started before node = Node.Instance; } }