Exemple #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Settings.Instance.Load();

            // Create your application here
            AddPreferencesFromResource(Resource.Layout.Settings);

            prefBlacklist = FindPreference("pref_blacklist");
            prefReorder   = FindPreference("pref_reorder");

            prefDisableHomeDetect = (CheckBoxPreference)FindPreference("pref_disablecheck");
            prefWallpaperUrl      = (EditTextPreference)FindPreference("pref_WallpaperUrl");

            prefBlacklist.PreferenceClick += delegate {
                StartActivity(typeof(SettingsAppShowHideActivity));
            };
            prefReorder.PreferenceClick += delegate {
                StartActivity(typeof(ReorderActivity));
            };

            // Start the intent service, it will decide to stop itself or not
            prefDisableHomeDetect.PreferenceChange += (sender, e) =>
                                                      StartService(new Intent(this, typeof(ExcuseMeService)));

            prefWallpaperUrl.PreferenceChange += (sender, e) => {
                AndHUD.Shared.Show(this, "Downloading Wallpaper...");

                var url = prefWallpaperUrl.EditText.Text;

                if (url.IndexOf("http://") == -1)
                {
                    url = string.Concat("http://", url);
                }

                Task.Run(() => {
                    try {
                        var http     = new System.Net.WebClient();
                        var bytes    = http.DownloadData(url);
                        var filename = Settings.GetWallpaperPath();
                        System.IO.File.WriteAllBytes(filename, bytes);
                    } catch (Exception ex) {
                        Settings.Instance.WallpaperUrl = string.Empty;
                        //Toast.MakeText (this, "Failed to Download Wallpaper", ToastLength.Long).Show ();
                        Log.Error("Downloading Wallpaper Failed", ex);
                    }

                    AndHUD.Shared.Dismiss(this);
                });
            };
        }
Exemple #2
0
        public static string GetWallpaperFilename()
        {
            try {
                var filename = Settings.GetWallpaperPath();

                if (File.Exists(filename))
                {
                    return(filename);
                }
            } catch {
            }

            return(null);
        }