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;

                Task.Factory.StartNew(() => {
                    try {
                        var http     = new System.Net.WebClient();
                        var bytes    = http.DownloadData(url);
                        var filename = Settings.GetWallpaperFilename();
                        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
        void Setup(bool dateOnly = false)
        {
            RunOnUiThread(() => {
                var timeFmt = "h:mm tt";
                if (Settings.Instance.TwentyFourHourTime)
                {
                    timeFmt = "H:mm";
                }
                textTime.Text = DateTime.Now.ToString(timeFmt);
                textDate.Text = DateTime.Now.ToString("dddd MMMM d").ToUpperInvariant();

                if (dateOnly)
                {
                    return;
                }

                frameTopBar.Visibility = Settings.Instance.HideTopBar ? ViewStates.Gone : ViewStates.Visible;

                frameTopBar.SetBackgroundColor(new Android.Graphics.Color(0, 0, 0, Settings.Instance.TopInfoBarBackgroundAlpha));

                var pad = Settings.Instance.HideTopBar ? gridView.PaddingBottom : gridViewTopPadding;

                gridView.SetPadding(gridView.PaddingLeft, pad, gridView.PaddingRight, gridView.PaddingBottom);

                wallpaper.Visibility = Settings.Instance.WallpaperUse ? ViewStates.Visible : ViewStates.Gone;

                if (Settings.Instance.WallpaperUse)
                {
                    var filename = Settings.GetWallpaperFilename();

                    if (string.IsNullOrEmpty(filename))
                    {
                        wallpaper.SetImageResource(Resource.Drawable.wallpaper);
                    }
                    else
                    {
                        try {
                            var drawable = Android.Graphics.Drawables.Drawable.CreateFromPath(filename);
                            wallpaper.SetImageDrawable(drawable);
                        } catch {
                            wallpaper.SetImageResource(Resource.Drawable.wallpaper);
                        }
                    }
                }
            });
        }