Example #1
0
        public virtual void AddPreferencesFromResource(Action <int> baseAddPreferencesFromResource, int preferencesResId)
        {
#if APPCOMPAT
            PreferenceFragment fragment = null;
#else
            var fragment = Target as PreferenceFragment;
#endif
            if (fragment == null)
            {
                Tracer.Error("The AddPreferencesFromResource method supported only for PreferenceFragment");
                return;
            }
            baseAddPreferencesFromResource(preferencesResId);
            InitializePreferences(fragment.PreferenceScreen, preferencesResId);
        }
Example #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            newTaskFragment    = new NewTaskFragment(this);
            historyFragment    = new HistoryFragment(this);
            donationFragment   = new DonationFragment();
            preferenceFragment = new PreferenceFragment(this);

            toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mainToolBar);
            SetSupportActionBar(toolbar);


            navigation = FindViewById <Google.Android.Material.BottomNavigation.BottomNavigationView>(Resource.Id.navigation);
            navigation.SetOnNavigationItemSelectedListener(this);

            ChangeFragment(newTaskFragment);

            MobileAds.Initialize(this);

            if (!ExtractRAdManager.UserHasDonated(this))
            {
                interstitialAd = ExtractRAdManager.LoadAdInBackground(this);
            }

            if (AppCompatDelegate.DefaultNightMode == AppCompatDelegate.ModeNightYes)
            {
                navigation.ItemIconTintList = Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.GhostWhite);
                navigation.ItemTextColor    = Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.GhostWhite);
            }
            else if (AppCompatDelegate.DefaultNightMode == AppCompatDelegate.ModeNightNo)
            {
                string accentColorString           = "#" + GetColor(Resource.Color.colorAccent).ToString("X");
                Android.Graphics.Color accentColor = Android.Graphics.Color.ParseColor(accentColorString);

                navigation.ItemIconTintList = Android.Content.Res.ColorStateList.ValueOf(accentColor);
                navigation.ItemTextColor    = Android.Content.Res.ColorStateList.ValueOf(accentColor);
            }
        }
            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);
                };
            }
            public KeyboardSwitchPrefManager(PreferenceFragment fragment)
            {
                var act = fragment.Activity;

                this._act      = act;
                this._fragment = fragment;

                _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));
                _screen = (PreferenceScreen)_fragment.FindPreference(act.GetString(Resource.String.keyboardswitch_prefs_key));
                EnableSwitchPreferences(_switchPref.Checked);

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