private void EnableSwitchPreferences(bool switchOnRooted)
            {
                if (!switchOnRooted)
                {
                    if (_fragment.FindPreference(_act.GetString(Resource.String.OpenKp2aKeyboardAutomatically_key)) == null)
                    {
                        _screen.AddPreference(_openKp2aAutoPref);
                    }
                    if (_fragment.FindPreference(_act.GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key)) != null)
                    {
                        _screen.RemovePreference(_openOnlyOnSearchPref);
                    }
                }
                else
                {
                    {
                        _screen.RemovePreference(_openKp2aAutoPref);
                    }
                    if (_fragment.FindPreference(_act.GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key)) == null)
                    {
                        _screen.AddPreference(_openOnlyOnSearchPref);
                    }
                }

                /*_openKp2aAutoPref.Enabled = !switchOnRooted;
                 *
                 * _openOnlyOnSearchPref.Enabled = switchOnRooted;
                 *
                 * _switchBackPref.Enabled = switchOnRooted;*/
            }
        private void PrepareNoDonationReminderPreference(Activity ctx, PreferenceScreen screen, Preference preference)
        {
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(ctx);

            if (!prefs.GetBoolean("DismissedDonateReminder", false))
            {
                screen.RemovePreference(preference);
            }
        }
        private void TogglePreferences()
        {
            var isTeacher = AndroidDependencyContainer.Instance.ScheduleSettings.IsUserTeacher;

            if (isTeacher)
            {
                PreferenceScreen.RemovePreference(groupNumberPreference);
                PreferenceScreen.AddPreference(teacherNamePreference);
            }
            else
            {
                PreferenceScreen.RemovePreference(teacherNamePreference);
                PreferenceScreen.AddPreference(groupNumberPreference);
            }
        }
            public KeyboardSwitchPrefManager(PreferenceFragment fragment)
            {
                var act = fragment.Activity;

                this._act      = act;
                this._fragment = fragment;
                this._screen   = (PreferenceScreen)_fragment.FindPreference(act.GetString(Resource.String.keyboardswitch_prefs_key));

                var keyboardSwapPref = _fragment.FindPreference("get_keyboardswap");
                var pm    = act.PackageManager;
                var intnt = Keepass2android.Kbbridge.ImeSwitcher.GetLaunchIntentForKeyboardSwap(act);

                if ((intnt != null) && pm.QueryIntentActivities(intnt, 0).Any())
                {
                    _screen.RemovePreference(keyboardSwapPref);
                }
                else
                {
                    keyboardSwapPref.PreferenceClick += (sender, args) =>
                    {
                        Util.GotoUrl(act, act.GetString(Resource.String.MarketURL) + "keepass2android.plugin.keyboardswap2");
                    };
                }

                _switchPref       = (CheckBoxPreference)_fragment.FindPreference("kp2a_switch_rooted");
                _openKp2aAutoPref =
                    (CheckBoxPreference)_fragment.FindPreference(act.GetString(Resource.String.OpenKp2aKeyboardAutomatically_key));
                _openOnlyOnSearchPref =
                    (CheckBoxPreference)
                    _fragment.FindPreference(act.GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key));
                _switchBackPref =
                    (CheckBoxPreference)_fragment.FindPreference(act.GetString(Resource.String.AutoSwitchBackKeyboard_key));

                EnableSwitchPreferences(_switchPref.Checked);

                _switchPref.PreferenceChange += (sender, args) =>
                {
                    bool switchOnRooted = (bool)args.NewValue;
                    EnableSwitchPreferences(switchOnRooted);
                };
            }