Ejemplo n.º 1
0
        protected override void InitBindings()
        {
            SettingsPageGeneralStartPageRadioGroup.Check(Settings.DefaultMenuTab == "anime"
                ? SettingsPageGeneralRadioAnimeList.Id
                : SettingsPageGeneralRadioMangaList.Id);
            SettingsPageGeneralStartPageRadioGroup.SetOnCheckedChangeListener(new OnCheckedListener(i =>
            {
                Settings.DefaultMenuTab = i == SettingsPageGeneralRadioAnimeList.Id ? "anime" : "manga";
            }));
            //
            SettingsPageGeneralThemeRadioGroup.Check(Settings.SelectedTheme == 1
                ? SettingsPageGeneralRadioDarkTheme.Id
                : SettingsPageGeneralRadioLightTheme.Id);

            SettingsPageGeneralThemeRadioGroup.SetOnCheckedChangeListener(new OnCheckedListener(i =>
            {
                Settings.SelectedTheme = i == SettingsPageGeneralRadioDarkTheme.Id ? 1 : 0;
                SettingsPageGeneralThemeChangeApply.Visibility =
                    Converters.BoolToVisibility(Settings.SelectedTheme != MainActivity.CurrentTheme || AndroidColourThemeHelper.CurrentTheme != MainActivity.CurrentAccent);
            }));
            SettingsPageGeneralThemeChangeApply.SetOnClickListener(new OnClickListener(view =>
            {
                MainActivity.CurrentContext.Recreate();
                ViewModelLocator.NavMgr.ResetMainBackNav();
            }));

            //


            Bindings.Add(
                this.SetBinding(() => ViewModel.PullHigherQualityImages,
                                () => SettingsPageGeneralPullHigherSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.DisplaySeasonWithType,
                                () => SettingsPageGeneralSeasonSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.AutoDescendingSorting,
                                () => SettingsPageGeneralAutoSortSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.MangaFocusVolumes,
                                () => SettingsPageGeneralVolsImportantSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.HamburgerHideMangaSection,
                                () => SettingsPageGeneralHideHamburgerMangaSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.EnableSwipeToIncDec,
                                () => SettingsPageGeneralEnableSwipeSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.PreferEnglishTitles,
                                () => SettingsPageGeneralPreferEnglishTitleSwitch.Checked, BindingMode.TwoWay));

            Bindings.Add(
                this.SetBinding(() => ViewModel.MakeGridItemsSmaller,
                                () => SettingsPageGeneralSmallerGridItems.Checked, BindingMode.TwoWay));

            Bindings.Add(
                this.SetBinding(() => ViewModel.ReverseSwipingDirection,
                                () => SettingsPageGeneralReverseSwipeOrder.Checked, BindingMode.TwoWay));

            Bindings.Add(
                this.SetBinding(() => ViewModel.DarkThemeAmoled,
                                () => SettingsPageGeneralAmoledSwitch.Checked, BindingMode.TwoWay));

            Bindings.Add(
                this.SetBinding(() => ViewModel.DisplayScoreDialogAfterCompletion,
                                () => SettingsPageGeneralDisplayScoreDialog.Checked, BindingMode.TwoWay));
            //

            SettingsPageGeneralAnimeSortRadioGroup.Check(GetViewIdForAnimeSortOption(Settings.AnimeSortOrder));
            SettingsPageGeneralAnimeSortRadioGroup.SetOnCheckedChangeListener(new OnCheckedListener(i =>
            {
                Settings.AnimeSortOrder = GetSortOptionForViewId(i);
            }));

            SettingsPageGeneralMangaSortRadioGroup.Check(GetViewIdForMangaSortOption(Settings.MangaSortOrder));
            SettingsPageGeneralMangaSortRadioGroup.SetOnCheckedChangeListener(new OnCheckedListener(i =>
            {
                Settings.MangaSortOrder = GetSortOptionForViewId(i);
            }));

            SettingsPageGeneralAnimeSortDescendingSwitch.Checked        = Settings.IsSortDescending;
            SettingsPageGeneralAnimeSortDescendingSwitch.CheckedChange +=
                (sender, args) => Settings.IsSortDescending             = SettingsPageGeneralAnimeSortDescendingSwitch.Checked;

            SettingsPageGeneralMangaSortDescendingSwitch.Checked        = Settings.IsMangaSortDescending;
            SettingsPageGeneralMangaSortDescendingSwitch.CheckedChange +=
                (sender, args) => Settings.IsMangaSortDescending        = SettingsPageGeneralMangaSortDescendingSwitch.Checked;
            //

            SettingsPageGeneralWatchingViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralWatchingViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForWatching));
            SettingsPageGeneralWatchingViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForWatching = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };

            SettingsPageGeneralCompletedViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralCompletedViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForCompleted));
            SettingsPageGeneralCompletedViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForCompleted = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };

            SettingsPageGeneralOnHoldViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralOnHoldViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForOnHold));
            SettingsPageGeneralOnHoldViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForOnHold = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };

            SettingsPageGeneralDroppedViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralDroppedViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForDropped));
            SettingsPageGeneralDroppedViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForDropped = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };

            SettingsPageGeneralPtwViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralPtwViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForPlanned));
            SettingsPageGeneralPtwViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForPlanned = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };

            SettingsPageGeneralAllViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralAllViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForAll));
            SettingsPageGeneralAllViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForAll = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };


            //
            var filters = Enum.GetValues(typeof(AnimeStatus)).Cast <int>().Take(5).ToList();

            SettingsPageGeneralMangaFilerSpinner.Adapter = filters.GetAdapter(GetMangaTemplateDelegate);
            SettingsPageGeneralMangaFilerSpinner.SetSelection(filters.IndexOf(Settings.DefaultMangaFilter));
            SettingsPageGeneralMangaFilerSpinner.ItemSelected += (sender, args) =>
            {
                Settings.DefaultMangaFilter = (int)SettingsPageGeneralMangaFilerSpinner.SelectedView.Tag;
            };

            SettingsPageGeneralAnimeFilterSpinner.Adapter = filters.GetAdapter(GetAnimeTemplateDelegate);
            SettingsPageGeneralAnimeFilterSpinner.SetSelection(filters.IndexOf(Settings.DefaultAnimeFilter));
            SettingsPageGeneralAnimeFilterSpinner.ItemSelected += (sender, args) =>
            {
                Settings.DefaultAnimeFilter = (int)SettingsPageGeneralAnimeFilterSpinner.SelectedView.Tag;
            };

            SettingsPageGeneralDefaultAddedStatusSpinner.Adapter = filters.GetAdapter(GetAnimeTemplateDelegate);
            SettingsPageGeneralDefaultAddedStatusSpinner.SetSelection(filters.IndexOf((int)Settings.DefaultStatusAfterAdding));
            SettingsPageGeneralDefaultAddedStatusSpinner.ItemSelected += (sender, args) =>
            {
                Settings.DefaultStatusAfterAdding = (AnimeStatus)(int)SettingsPageGeneralDefaultAddedStatusSpinner.SelectedView.Tag;
            };
            //


            Bindings.Add(
                this.SetBinding(() => ViewModel.SetStartDateOnListAdd,
                                () => SettingsPageGeneralStartDateWhenAddCheckBox.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.SetStartDateOnWatching,
                                () => SettingsPageGeneralStartDateWhenWatchCheckBox.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.SetEndDateOnCompleted,
                                () => SettingsPageGeneralEndDateWhenCompleted.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.SetEndDateOnDropped,
                                () => SettingsPageGeneralEndDateWhenDropCheckBox.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.OverrideValidStartEndDate,
                                () => SettingsPageGeneralAllowDateOverrideCheckBox.Checked, BindingMode.TwoWay));
            //
            SettingsPageGeneralAirDayOffsetSlider.Progress = Settings.AirDayOffset + 3;
            SettingsPageGeneralAirDayOffsetTextView.Text   = (Settings.AirDayOffset).ToString();

            SettingsPageGeneralAirDayOffsetSlider.ProgressChanged += (sender, args) =>
            {
                Settings.AirDayOffset = SettingsPageGeneralAirDayOffsetSlider.Progress - 3;
                SettingsPageGeneralAirDayOffsetTextView.Text =
                    (SettingsPageGeneralAirDayOffsetSlider.Progress - 3).ToString();
            };

            SettingsPageGeneralAiringNotificationOffsetSlider.Progress = Settings.AiringNotificationOffset + 24;
            SettingsPageGeneralAiringNotificationOffsetTextView.Text   = Settings.AiringNotificationOffset.ToString();

            SettingsPageGeneralAiringNotificationOffsetSlider.ProgressChanged += (sender, args) =>
            {
                Settings.AiringNotificationOffset = SettingsPageGeneralAiringNotificationOffsetSlider.Progress - 24;
                SettingsPageGeneralAiringNotificationOffsetTextView.Text =
                    (SettingsPageGeneralAiringNotificationOffsetSlider.Progress - 24).ToString();
            };

            Bindings.Add(this.SetBinding(() => ViewModel.DarkThemeAmoled).WhenSourceChanges(UpdateColourSelection));



            SettingsPageGeneralColorOrange.Tag = (int)AndroidColorThemes.Orange;
            SettingsPageGeneralColorPurple.Tag = (int)AndroidColorThemes.Purple;
            SettingsPageGeneralColorBlue.Tag   = (int)AndroidColorThemes.Blue;
            SettingsPageGeneralColorLime.Tag   = (int)AndroidColorThemes.Lime;
            SettingsPageGeneralColorPink.Tag   = (int)AndroidColorThemes.Pink;

            var colorListener = new OnClickListener(view =>
            {
                AndroidColourThemeHelper.CurrentTheme = (AndroidColorThemes)(int)view.Tag;
                UpdateColourSelection();
            });

            SettingsPageGeneralColorOrange.SetOnClickListener(colorListener);
            SettingsPageGeneralColorPurple.SetOnClickListener(colorListener);
            SettingsPageGeneralColorBlue.SetOnClickListener(colorListener);
            SettingsPageGeneralColorLime.SetOnClickListener(colorListener);
            SettingsPageGeneralColorPink.SetOnClickListener(colorListener);
        }
Ejemplo n.º 2
0
        protected override void InitBindings()
        {
            SettingsPageGeneralStartPageRadioGroup.Check(Settings.DefaultMenuTab == "anime"
                ? SettingsPageGeneralRadioAnimeList.Id
                : SettingsPageGeneralRadioMangaList.Id);
            SettingsPageGeneralStartPageRadioGroup.SetOnCheckedChangeListener(new OnCheckedListener(i =>
            {
                Settings.DefaultMenuTab = i == SettingsPageGeneralRadioAnimeList.Id ? "anime" : "manga";
            }));
            //
            SettingsPageGeneralThemeRadioGroup.Check(Settings.SelectedTheme == 1
                ? SettingsPageGeneralRadioDarkTheme.Id
                : SettingsPageGeneralRadioLightTheme.Id);

            SettingsPageGeneralThemeRadioGroup.SetOnCheckedChangeListener(new OnCheckedListener(i =>
            {
                Settings.SelectedTheme = i == SettingsPageGeneralRadioDarkTheme.Id ? 1 : 0;
                SettingsPageGeneralThemeChangeNotice.Visibility =
                    Converters.BoolToVisibility(Settings.SelectedTheme != MainActivity.CurrentTheme);
            }));
            //

            Bindings.Add(
                this.SetBinding(() => ViewModel.PullHigherQualityImages,
                                () => SettingsPageGeneralPullHigherSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.DisplaySeasonWithType,
                                () => SettingsPageGeneralSeasonSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.AutoDescendingSorting,
                                () => SettingsPageGeneralAutoSortSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.MangaFocusVolumes,
                                () => SettingsPageGeneralVolsImportantSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.EnsureRandomizerAlwaysSelectsWinner,
                                () => SettingsPageGeneralRandomSelectedSwitch.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.ArticlesLaunchExternalLinks,
                                () => SettingsPageGeneralExternalLinksSwitch.Checked, BindingMode.TwoWay));
            //
            SettingsPageGeneralAnimeSortRadioGroup.Check(GetViewIdForAnimeSortOption(Settings.AnimeSortOrder));
            SettingsPageGeneralAnimeSortRadioGroup.SetOnCheckedChangeListener(new OnCheckedListener(i =>
            {
                Settings.AnimeSortOrder = GetSortOptionForViewId(i);
            }));

            SettingsPageGeneralMangaSortRadioGroup.Check(GetViewIdForMangaSortOption(Settings.MangaSortOrder));
            SettingsPageGeneralMangaSortRadioGroup.SetOnCheckedChangeListener(new OnCheckedListener(i =>
            {
                Settings.MangaSortOrder = GetSortOptionForViewId(i);
            }));

            SettingsPageGeneralAnimeSortDescendingSwitch.Checked        = Settings.IsSortDescending;
            SettingsPageGeneralAnimeSortDescendingSwitch.CheckedChange +=
                (sender, args) => Settings.IsSortDescending             = SettingsPageGeneralAnimeSortDescendingSwitch.Checked;

            SettingsPageGeneralMangaSortDescendingSwitch.Checked        = Settings.IsMangaSortDescending;
            SettingsPageGeneralMangaSortDescendingSwitch.CheckedChange +=
                (sender, args) => Settings.IsMangaSortDescending        = SettingsPageGeneralMangaSortDescendingSwitch.Checked;
            //

            SettingsPageGeneralWatchingViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralWatchingViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForWatching));
            SettingsPageGeneralWatchingViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForWatching = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };

            SettingsPageGeneralCompletedViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralCompletedViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForCompleted));
            SettingsPageGeneralCompletedViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForCompleted = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };

            SettingsPageGeneralOnHoldViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralOnHoldViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForOnHold));
            SettingsPageGeneralOnHoldViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForOnHold = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };

            SettingsPageGeneralDroppedViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralDroppedViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForDropped));
            SettingsPageGeneralDroppedViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForDropped = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };

            SettingsPageGeneralPtwViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralPtwViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForPlanned));
            SettingsPageGeneralPtwViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForPlanned = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };

            SettingsPageGeneralAllViewModeSpinner.Adapter = ViewModel.DisplayModes.GetAdapter(GetTemplateDelegate);
            SettingsPageGeneralAllViewModeSpinner.SetSelection(ViewModel.DisplayModes.IndexOf(ViewModel.SelectedDefaultViewForAll));
            SettingsPageGeneralAllViewModeSpinner.ItemSelected += (sender, args) =>
            {
                ViewModel.SelectedDefaultViewForAll = (sender as Spinner).SelectedView.Tag.Unwrap <Tuple <AnimeListDisplayModes, string> >();
            };


            Bindings.Add(
                this.SetBinding(() => ViewModel.LockDisplayMode,
                                () => SettingsGeneralPageLockDisplayModeSwitch.Checked, BindingMode.TwoWay));
            //
            var filters = Enum.GetValues(typeof(AnimeStatus)).Cast <int>().ToList();

            SettingsPageGeneralMangaFilerSpinner.Adapter = filters.GetAdapter(GetMangaTemplateDelegate);
            SettingsPageGeneralMangaFilerSpinner.SetSelection(filters.IndexOf(Settings.DefaultMangaFilter));
            SettingsPageGeneralMangaFilerSpinner.ItemSelected += (sender, args) =>
            {
                Settings.DefaultMangaFilter = (int)SettingsPageGeneralMangaFilerSpinner.SelectedView.Tag;
            };

            SettingsPageGeneralAnimeFilterSpinner.Adapter = filters.GetAdapter(GetAnimeTemplateDelegate);
            SettingsPageGeneralAnimeFilterSpinner.SetSelection(filters.IndexOf(Settings.DefaultAnimeFilter));
            SettingsPageGeneralAnimeFilterSpinner.ItemSelected += (sender, args) =>
            {
                Settings.DefaultAnimeFilter = (int)SettingsPageGeneralAnimeFilterSpinner.SelectedView.Tag;
            };
            //


            Bindings.Add(
                this.SetBinding(() => ViewModel.SetStartDateOnListAdd,
                                () => SettingsPageGeneralStartDateWhenAddCheckBox.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.SetStartDateOnWatching,
                                () => SettingsPageGeneralStartDateWhenWatchCheckBox.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.SetEndDateOnCompleted,
                                () => SettingsPageGeneralEndDateWhenCompleted.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.SetEndDateOnDropped,
                                () => SettingsPageGeneralEndDateWhenDropCheckBox.Checked, BindingMode.TwoWay));
            Bindings.Add(
                this.SetBinding(() => ViewModel.OverrideValidStartEndDate,
                                () => SettingsPageGeneralAllowDateOverrideCheckBox.Checked, BindingMode.TwoWay));
            //
            SettingsPageGeneralAirDayOffsetSlider.Progress = Settings.AirDayOffset + 3;
            SettingsPageGeneralAirDayOffsetTextView.Text   = (Settings.AirDayOffset).ToString();

            SettingsPageGeneralAirDayOffsetSlider.ProgressChanged += (sender, args) =>
            {
                Settings.AirDayOffset = SettingsPageGeneralAirDayOffsetSlider.Progress - 3;
                SettingsPageGeneralAirDayOffsetTextView.Text =
                    (SettingsPageGeneralAirDayOffsetSlider.Progress - 3).ToString();
            };
        }