// <summary> // Set a new IPreferencesProvider. Calls to Get/Set will immediately // use the new provider. // </summary> public static void SetPreferencesProvider(IPreferencesProvider newProvider) { if (newProvider != null) { provider = newProvider; } }
public DefaultIrrKlangEngineProvider(IPreferencesProvider <double> preferences) { this.Preferences = preferences; //add our BIN directory to our local path: need to load MP3 and flac plugins string path = System.Reflection.Assembly.GetEntryAssembly().Location; path = new Regex(@"[^\\]+$").Replace(path, ""); path = System.Environment.GetEnvironmentVariable("Path") + ";" + path; System.Environment.SetEnvironmentVariable("Path", path); //start the sound engine Engine = new ISoundEngine(); }
/// <summary> /// Save settings /// </summary> /// <param name="preferencesProvider">The preferences provider</param> public void SaveSettings(IPreferencesProvider preferencesProvider) { if (preferencesProvider != null) { #if !SILVERLIGHT preferencesProvider.SetString("LastSavePath", _lastSavePath); preferencesProvider.SetInt32("ProxyMode", _proxyMode); preferencesProvider.SetString("ProxyAddress", _proxyAddress); preferencesProvider.SetInt32("ProxyPort", _proxyPort); #endif } }
/// <summary> /// Load settings /// </summary> /// <param name="preferencesProvider">The preferences provider</param> public void LoadSettings(IPreferencesProvider preferencesProvider) { if (preferencesProvider != null) { #if !SILVERLIGHT _lastSavePath = preferencesProvider.GetString("LastSavePath", ""); _proxyMode = preferencesProvider.GetInt32("ProxyMode", _proxyMode); _proxyAddress = preferencesProvider.GetString("ProxyAddress", _proxyAddress); _proxyPort = preferencesProvider.GetInt32("ProxyPort", _proxyPort); Obany.Communications.HttpChannel.SetProxy(_proxyMode, _proxyAddress, _proxyPort); #endif } }
public DefaultVirtualVolumeService(IPreferencesProvider <double> preferences) { this.Preferences = preferences; }
static Preferences() { // Use the GConf provider by default provider = new GConfPreferencesProvider(); }
protected override void OnCreate(Bundle savedInstanceState) { AndroidApplication = Application as AndroidApplication; AndroidApplication.Logger.Debug(() => "MainActivity:OnCreate"); base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); DriveInfoProvider = AndroidApplication.IocContainer.Resolve <IDriveInfoProvider>(); FileSystemHelper = AndroidApplication.IocContainer.Resolve <IFileSystemHelper>(); PreferencesProvider = AndroidApplication.IocContainer.Resolve <IPreferencesProvider>(); ControlFileUri = PreferencesProvider.GetPreferenceString(ApplicationContext.GetString(Resource.String.prefs_control_uri_key), ""); AndroidApplication.Logger.Debug(() => $"MainActivity:OnCreate Conrol Uri = {ControlFileUri}"); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); // Get our UI controls from the loaded layout List <string> envirnment = WindowsEnvironmentInformationProvider.GetEnvironmentRuntimeDisplayInformation(); StringBuilder builder = new StringBuilder(); builder.AppendLine(AndroidApplication.DisplayVersion); foreach (string line in envirnment) { builder.AppendLine(line); } SetTextViewText(Resource.Id.txtVersions, builder.ToString()); builder.Clear(); builder.AppendLine($"Personal Folder = {System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)}"); builder.AppendLine($"AppData Folder = {System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData)}"); builder.AppendLine($"CommonAppData Folder = {System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData)}"); Java.IO.File[] files = ApplicationContext.GetExternalFilesDirs(null); foreach (Java.IO.File file in files) { builder.AppendLine($"ExternalFile = {file.AbsolutePath}"); OverrideRoot = file.AbsolutePath; } builder.AppendLine($"Podcasts Folder = {Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPodcasts).AbsolutePath}"); SetTextViewText(Resource.Id.txtAppStorage, builder.ToString()); ProgressSpinner = FindViewById <ProgressSpinnerView>(Resource.Id.progressBar); Button btnLoad = FindViewById <Button>(Resource.Id.btnLoadConfig); btnLoad.Click += (sender, e) => LoadConfig(); Button btnFind = FindViewById <Button>(Resource.Id.btnFindPodcasts); // works btnFind.Click += (sender, e) => Task.Run(() => FindEpisodesToDownload()); // crash - java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() //btnFind.Click += async (sender, e) => await Task.Run(() => FindEpisodesToDownload()); // blocks UI thread //btnFind.Click += async (sender, e) => FindEpisodesToDownload(); Button btnSetRoot = FindViewById <Button>(Resource.Id.btnSetRoot); btnSetRoot.Click += (sender, e) => SetRoot(); Button btnDownload = FindViewById <Button>(Resource.Id.btnDownload); btnDownload.Click += (sender, e) => Task.Run(() => Download()); bool isReadonly = Android.OS.Environment.MediaMountedReadOnly.Equals(Android.OS.Environment.ExternalStorageState); bool isWriteable = Android.OS.Environment.MediaMounted.Equals(Android.OS.Environment.ExternalStorageState); if (!string.IsNullOrEmpty(ControlFileUri)) { try { // TODO - we need to ask permission if the file has been edited by another app Android.Net.Uri uri = Android.Net.Uri.Parse(ControlFileUri); AndroidApplication.ControlFile = OpenControlFile(uri); } catch (Exception ex) { AndroidApplication.Logger.LogException(() => $"MainActivity: OnCreate", ex); SetTextViewText(Resource.Id.txtConfigFilePath, $"Error {ex.Message}"); } } }
// <summary> // Set a new IPreferencesProvider. Calls to Get/Set will immediately // use the new provider. // </summary> public static void SetPreferencesProvider(IPreferencesProvider newProvider) { if (newProvider != null) provider = newProvider; }
static Preferences() { // Use the GConf provider by default provider = new GConfPreferencesProvider (); }
public DummyVolumeService(IPreferencesProvider <double> preferences, IServiceProvider serviceProvider) { this.Preferences = preferences; this.ServiceProvider = serviceProvider; }